-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: 2.2.25, 2.2.34, 3.0.1
-
Component/s: None
-
Empty show more show less
db.getCollection is catching our application errors and calling the callback we pass to it twice.
We call db.collection has follows:
db.collection(collectionName, callback);
The callback then executes our application code (in the same tick). If we throw an error it is being caught by the code in db.collection which then calls the callback again which I believe is incorrect behaviour.
I can see this was attempted to be fixed 8 months ago by @christkv but it looks like the line that actually makes the fix work is commented out:
https://github.com/mongodb/node-mongodb-native/blame/2.2/lib/db.js#L466
I've also noticed that a lot of the asynchronous methods in the mongo driver invoke handleCallback which introduces an asynchronous break to the code flow. Would that be an alternative fix for this issue?