Skip to content

Commit

Permalink
fix(count-documents): return callback on error case
Browse files Browse the repository at this point in the history
otherwise the scucess handler is called, which results into further missleading errors (e.g. length is not defined)
  • Loading branch information
simllll authored and mbroadst committed Jul 8, 2018
1 parent d080143 commit fca1185
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/operations/collection_ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ function countDocuments(coll, query, options, callback) {
coll.aggregate(pipeline, options, (err, result) => {
if (err) return handleCallback(callback, err);
result.toArray((err, docs) => {
if (err) handleCallback(err);
if (err) return handleCallback(err);
handleCallback(callback, null, docs.length ? docs[0].n : 0);
});
});
Expand Down

0 comments on commit fca1185

Please sign in to comment.