diff --git a/lib/drivers/node-mongodb-native/collection.js b/lib/drivers/node-mongodb-native/collection.js index 1e4678ff93..b3500d7753 100644 --- a/lib/drivers/node-mongodb-native/collection.js +++ b/lib/drivers/node-mongodb-native/collection.js @@ -138,8 +138,14 @@ function iter(i) { let promise = null; let timeout = null; if (syncCollectionMethods[i] && typeof lastArg === 'function') { + callback = function collectionOperationCallback() { + if (timeout != null) { + clearTimeout(timeout); + } + return lastArg.apply(this, arguments); + }; + _args = args.slice(0, args.length - 1).concat([callback]); this.addQueue(i, _args); - callback = lastArg; } else if (syncCollectionMethods[i]) { promise = new this.Promise((resolve, reject) => { callback = function collectionOperationCallback(err, res) {