Skip to content

Conversation

@medikoo
Copy link
Contributor

@medikoo medikoo commented Mar 13, 2013

Inner Logic of _executeQueryCommand result looks as:

var getMore = function(self, options, callback) { // ... self.db._executeQueryCommand(a, b, function(err, result) { // ... try { // ... callback(null, value); // ... } catch (e) { // ... callback(err); // ... } }); // ... };

It means that eventual error thrown within callback is propagated back to same callback. That's unexpected, additionally in that case async function callback is called twice, which should never happen.

This patch fixes that to:

self.db._executeQueryCommand(a, b, function(err, result) { var cbValue; // ... try { // ... cbValue = value; // ... } catch (e) { // ... callback(err); // ... } if (cbValue != null) callback(null, cbValue); });

Callback is not called with it's own error, and error is freely thrown as it should in such case.

Inner Logic of executeQueryCommand result looks as: self.db._executeQueryCommand(a, b, function(err, result) { // ... try { // ... callback(null, value); // ... } catch (e) { // ... callback(err); // ... } }); It means that eventual error thrown within callback will be propagated back to same callback. This commit fixes that, so it logic is: self.db._executeQueryCommand(a, b, function(err, result) { var cbValue; // ... try { // ... cbValue = value; // ... } catch (e) { // ... callback(err); // ... } if (cbValue) callback(null, cbValue); }); Callback is not called with it's own error, and that one is freely thrown.
@christkv christkv merged commit 7acce75 into mongodb:master Mar 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants