Skip to content

Commit fca1185

Browse files
simllllmbroadst
authored andcommitted
fix(count-documents): return callback on error case
otherwise the scucess handler is called, which results into further missleading errors (e.g. length is not defined)
1 parent d080143 commit fca1185

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/operations/collection_ops.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ function countDocuments(coll, query, options, callback) {
233233
coll.aggregate(pipeline, options, (err, result) => {
234234
if (err) return handleCallback(callback, err);
235235
result.toArray((err, docs) => {
236-
if (err) handleCallback(err);
236+
if (err) return handleCallback(err);
237237
handleCallback(callback, null, docs.length ? docs[0].n : 0);
238238
});
239239
});

0 commit comments

Comments
 (0)