Skip to content

Commit e257e6b

Browse files
authored
fix(find): correctly translate timeout option into noCursorTimeout (#2700)
The find command's `timeout` option was incorrectly being translated into `noCursorTimeout`, this has been corrected to be `!timeout`. NODE-2828
1 parent 60936dc commit e257e6b

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/collection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ Collection.prototype.find = deprecateOptions(
429429
}
430430

431431
// Translate to new command option noCursorTimeout
432-
if (typeof newOptions.timeout === 'boolean') newOptions.noCursorTimeout = newOptions.timeout;
432+
if (typeof newOptions.timeout === 'boolean') newOptions.noCursorTimeout = !newOptions.timeout;
433433

434434
decorateCommand(findCommand, newOptions, ['session', 'collation']);
435435

test/functional/find.test.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,19 +1195,23 @@ describe('Find', function() {
11951195

11961196
// The actual test we wish to run
11971197
test: function(done) {
1198-
var configuration = this.configuration;
1199-
var client = configuration.newClient(configuration.writeConcernMax(), { poolSize: 1 });
1198+
const configuration = this.configuration;
1199+
const client = configuration.newClient(configuration.writeConcernMax(), { poolSize: 1 });
12001200
client.connect(function(err, client) {
1201-
var db = client.db(configuration.db);
1201+
const db = client.db(configuration.db);
12021202
db.createCollection('timeoutFalse', function(err, collection) {
1203+
expect(err).to.not.exist;
12031204
collection.find({}, { timeout: false }, function(err, cursor) {
1204-
test.equal(false, cursor.cmd.noCursorTimeout);
1205+
expect(err).to.not.exist;
1206+
expect(cursor.cmd.noCursorTimeout).to.be.true;
12051207

12061208
collection.find({}, { timeout: true }, function(err, cursor) {
1207-
test.equal(true, cursor.cmd.noCursorTimeout);
1209+
expect(err).to.not.exist;
1210+
expect(cursor.cmd.noCursorTimeout).to.be.false;
12081211

12091212
collection.find({}, {}, function(err, cursor) {
1210-
test.ok(!cursor.cmd.noCursorTimeout);
1213+
expect(err).to.not.exist;
1214+
expect(cursor.cmd.noCursorTimeout).to.not.exist;
12111215

12121216
client.close(done);
12131217
});

0 commit comments

Comments
 (0)