New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MongoDB connection loss during request in progress causing unhandled exception to crash node. #9355
Comments
Just re-tested, something like findOne works fine, the problem is with insertMany in my case. Not sure about other "*Many" methods |
I've made a deeper investigation and it seems the problem is in insertMany method at the line 3320: It seems it is not considered that there can be errors other than writeErrors and therefore if there is an error not related to writing (e.g. connection timeout error) - it just crashes at the line pasted above as it can't .map over undefined. in node14, adding optional chaining like this: Please fix it in the lib. |
connection error: MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017 |
im having this error its been a week, i cant find a solution |
@Nate97320 please open a new issue and follow the issue template. |
Do you want to request a feature or report a bug?
Bug
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
The behavior I expect is to be able to at least catch all the possible errors to avoid crashing the whole process.
Also, connection timeouts should be handled within the library itself.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
node 14,
"mongodb": "^3.6.0",
"mongoose": "^5.10.0",
The text was updated successfully, but these errors were encountered: