When i creating indexes via createIndex
or ensureIndex
methods my node.js app crashing without providing any details of occured error.
Also i have noticed that all my code works very well with my localhost mongodb until i use remote mongdb atlas replica set.
Node.js: 8.5.0 Mongodb: 3.6.4 Mongodb driver for Node.js: 3.0.8
Example code (but i have tried different variants of implementation, nothing helps):
db.collection('stars').ensureIndex({name: 1}, { unique: true });
I am already listening for uncaughtException
and unhandledRejection
events, but they dont fire on this crash.
What can i do to get details or get rid of this error?
Thanks for any help!
I updated my mongodb driver to version 3.1.0 and eventually got error message with description of reason that causes the problem. According to error message: "The field "retryWrites" is not valid for for an index specification". So, i think the problem was with this field that i used to add to my connection uri string. After removing this field i got rid of this problem.
The problem might be connected with this issue: NODE-1641. I've got similar problem and found a few solutions:
db.collection('stars').ensureIndex({name: 1}, { unique: true, retryWrites: null })
;However you need to check if it won't turn off retryable writes for that collection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With