Skip to content

Commit 3e4f76a

Browse files
emadumljhaywar
authored andcommitted
fix(find): correctly translate timeout option into noCursorTimeout (#2708)
NODE-2828
1 parent d123870 commit 3e4f76a

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/cmap/connection.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ export class Connection extends EventEmitter {
439439
}
440440

441441
if (typeof options.timeout === 'boolean') {
442-
query.noCursorTimeout = options.timeout;
442+
query.noCursorTimeout = !options.timeout;
443443
} else if (typeof options.noCursorTimeout === 'boolean') {
444444
query.noCursorTimeout = options.noCursorTimeout;
445445
}

src/operations/find.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ function makeFindCommand(ns: MongoDBNamespace, filter: Document, options: FindOp
264264
}
265265

266266
if (typeof options.timeout === 'boolean') {
267-
findCommand.noCursorTimeout = options.timeout;
267+
findCommand.noCursorTimeout = !options.timeout;
268268
} else if (typeof options.noCursorTimeout === 'boolean') {
269269
findCommand.noCursorTimeout = options.noCursorTimeout;
270270
}

test/functional/find.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ describe('Find', function () {
11311131
const db = client.db(this.configuration.db);
11321132
db.createCollection('cursor_timeout_false_0', (err, collection) => {
11331133
expect(err).to.not.exist;
1134-
const cursor = collection.find({}, { timeout: true });
1134+
const cursor = collection.find({}, { timeout: false });
11351135
cursor.toArray(err => {
11361136
expect(err).to.not.exist;
11371137
expect(events[0]).nested.property('command.noCursorTimeout').to.equal(true);

0 commit comments

Comments
 (0)