Skip to content

Commit 2ba67a7

Browse files
committed
Rewind cursor to correctly force reconnect on capped collections when first query comes back empty.
1 parent 9293941 commit 2ba67a7

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed

HISTORY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
-----------------
33
* Bug fixes for APM upconverting of legacy INSERT/UPDATE/REMOVE wire protocol messages.
44
* NODE-562, fixed issue where a Replicaset MongoDB URI with a single seed and replSet name set would cause a single direct connection instead of topology discovery.
5-
* Updated mongodb-core to 1.2.13.
5+
* Updated mongodb-core to 1.2.14.
66
* NODE-563 Introduced options.ignoreUndefined for db class and MongoClient db options, made serialize undefined to null default again but allowing for overrides on insert/update/delete operations.
77
* Use handleCallback if result is an error for count queries. (Issue #1298, https://github.com/agclever)
8+
* Rewind cursor to correctly force reconnect on capped collections when first query comes back empty.
89

910
2.0.43 09-14-2015
1011
-----------------

lib/cursor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ var nextObject = function(self, callback) {
641641
self.s.currentNumberOfRetries = self.s.currentNumberOfRetries - 1;
642642

643643
return setTimeout(function() {
644+
self.rewind();
644645
self.nextObject(callback);
645646
}, self.s.tailableRetryInterval);
646647
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"legacy"
1414
],
1515
"dependencies": {
16-
"mongodb-core": "1.2.13"
16+
"mongodb-core": "1.2.14"
1717
, "readable-stream": "1.0.31"
1818
, "es6-promise": "2.1.1"
1919
},

test/functional/mongo_client_tests.js

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,44 @@ exports["correctly timeout MongoClient connect using custom connectTimeoutMS"] =
366366
var start = new Date();
367367

368368
MongoClient.connect('mongodb://example.com/test?connectTimeoutMS=1000&maxPoolSize=1', function(err, db) {
369-
// db.close();
369+
test.ok(err != null);
370+
test.ok((new Date().getTime() - start.getTime()) >= 1000)
371+
test.done();
372+
});
373+
}
374+
}
370375

371-
var end = new Date();
372-
console.dir(end.getTime() - start.getTime())
376+
/**
377+
* @ignore
378+
*/
379+
exports["correctly error out when no socket available on MongoClient.connect"] = {
380+
metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } },
381+
382+
// The actual test we wish to run
383+
test: function(configuration, test) {
384+
var MongoClient = configuration.require.MongoClient;
385+
MongoClient.connect('mongodb://localhost:27088/test', function(err, db) {
386+
test.ok(err != null);
373387

374388
test.done();
375389
});
376390
}
377391
}
392+
393+
/**
394+
* @ignore
395+
*/
396+
exports["correctly error out when no socket available on MongoClient.connect with domain"] = {
397+
metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] } },
398+
399+
// The actual test we wish to run
400+
test: function(configuration, test) {
401+
var MongoClient = configuration.require.MongoClient;
402+
403+
MongoClient.connect('mongodb://test.com:80/test', function(err, db) {
404+
test.ok(err != null);
405+
406+
test.done();
407+
});
408+
}
409+
}

0 commit comments

Comments
 (0)