Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(find): correctly translate timeout option into noCursorTimeout #2708

Merged
merged 3 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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