Skip to content

Commit

Permalink
fix(find): correctly translate timeout option into noCursorTimeout (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
emadum authored Jan 20, 2021
1 parent 518655d commit 16a22c4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cmap/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ export class Connection extends EventEmitter {
}

if (typeof options.timeout === 'boolean') {
query.noCursorTimeout = options.timeout;
query.noCursorTimeout = !options.timeout;
} else if (typeof options.noCursorTimeout === 'boolean') {
query.noCursorTimeout = options.noCursorTimeout;
}
Expand Down
2 changes: 1 addition & 1 deletion src/operations/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ function makeFindCommand(ns: MongoDBNamespace, filter: Document, options: FindOp
}

if (typeof options.timeout === 'boolean') {
findCommand.noCursorTimeout = options.timeout;
findCommand.noCursorTimeout = !options.timeout;
} else if (typeof options.noCursorTimeout === 'boolean') {
findCommand.noCursorTimeout = options.noCursorTimeout;
}
Expand Down
2 changes: 1 addition & 1 deletion test/functional/find.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ describe('Find', function () {
const db = client.db(this.configuration.db);
db.createCollection('cursor_timeout_false_0', (err, collection) => {
expect(err).to.not.exist;
const cursor = collection.find({}, { timeout: true });
const cursor = collection.find({}, { timeout: false });
cursor.toArray(err => {
expect(err).to.not.exist;
expect(events[0]).nested.property('command.noCursorTimeout').to.equal(true);
Expand Down

0 comments on commit 16a22c4

Please sign in to comment.