Skip to content

feat(NODE-7958): make timeoutMS a no-op and deprecate it - #5085

Merged
johnmtll merged 13 commits into
mainfrom
NODE-7958
Oct 30, 2026
Merged

johnmtll merged 13 commits into
mainfrom
NODE-7958

Conversation

@tadjik1

@tadjik1 tadjik1 commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Description

Summary of Changes

timeoutMS and timeoutMode are now deprecated no-ops. They are still accepted everywhere (client options, URI, Db, Collection, operations, etc.) but ignored, so passing them sets nothing and never throws. A CSOT timeout context can no longer be created, and every operation uses the legacy timeouts (serverSelectionTimeoutMS, waitQueueTimeoutMS, socketTimeoutMS, maxTimeMS), which are unchanged.

Notes for Reviewers
  • The CSOT classes, CursorTimeoutMode and the cursor guards are now unreachable. They are left in place for the removal work.
  • Skipped tests are marked NODE-7958: timeoutMS is a no-op.
  • The runtime deprecation warning fires only for a client-level timeoutMS. Warnings for per-operation timeoutMS, timeoutMode and MongoOperationTimeoutError are tracked in NODE-7871.

Release Highlight

timeoutMS is deprecated and now a no-op

Warning

timeoutMS and timeoutMode are deprecated and have no effect starting in this release. They are still accepted and will not throw, but operations will no longer time out because of them. They are slated for removal in a future release.

Use the per-stage timeouts instead: serverSelectionTimeoutMS, waitQueueTimeoutMS, socketTimeoutMS, and maxTimeMS for server-side execution.

Double check the following

  • Lint is passing (npm run check:lint)
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@tadjik1
tadjik1 marked this pull request as ready for review October 29, 2026 16:35
Copilot AI balanced review requested due to automatic review settings October 29, 2026 16:35
@tadjik1
tadjik1 requested a review from a team as a code owner October 29, 2026 16:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Empty timeoutMS URI values still throw instead of being ignored, and removing the public MongoOptions.timeoutMS member breaks existing TypeScript code.

2 open issues
What changed in this PR

This PR deprecates timeoutMS and timeoutMode in the MongoDB Node.js driver and makes them no-ops, directing applications to the existing per-stage timeouts.

Changes:

  • Disables client-side operation timeout creation and propagation across operations, sessions, cursors, change streams, and GridFS.
  • Adds deprecation annotations and a client-level warning, and removes obsolete timeout validation.
  • Updates no-op coverage and skips tests that require the retired timeout behavior.
File Description
test/​unit/​utils.test.ts Tests ignored timeout options and preserved write concern timeouts.
test/​unit/​timeout.test.ts Expects legacy timeout contexts despite timeoutMS.
test/​unit/​sessions.test.ts Updates session timeout inheritance expectations.
test/​unit/​mongo_client.test.ts Tests ignored client and URI timeout values.
test/​unit/​cursor/​aggregation_cursor.test.ts Skips obsolete cursor timeout guard tests.
test/​unit/​client-side-encryption/​client_encryption.test.ts Expects no explicit encryption timeout setting.
test/​unit/​assorted/​uri_options.spec.test.ts Adjusts URI expectations for ignored timeoutMS.
test/​integration/​read-write-concern/​write_concern.test.ts Skips timeout-dependent write concern tests.
test/​integration/​node-specific/​timeout_ms_noop.test.ts Adds operation-level no-op integration coverage.
test/​integration/​node-specific/​auto_connect.test.ts Skips timeout-dependent auto-connect tests.
test/​integration/​node-specific/​abstract_cursor.test.ts Skips externally supplied timeout context tests.
test/​integration/​crud/​find_cursor_methods.test.ts Uses a legacy context in cursor tests.
test/​integration/​crud/​explain.test.ts Skips timeout-dependent explain tests.
test/​integration/​crud/​client_bulk_write.test.ts Unconditionally skips client-side timeout tests.
test/​integration/​client-side-operations-timeout/​node_csot.test.ts Skips driver-specific operation timeout tests.
test/​integration/​client-side-operations-timeout/​client_side_operations_timeout.unit.test.ts Skips operation timeout specification unit tests.
test/​integration/​client-side-operations-timeout/​client_side_operations_timeout.spec.test.ts Excludes retired timeout specs while retaining legacy filtering.
test/​integration/​client-side-operations-timeout/​client_side_operations_timeout.prose.test.ts Skips operation timeout prose tests.
test/​integration/​client-side-encryption/​driver.test.ts Skips encryption timeout suites.
test/​integration/​client-side-encryption/​client_side_encryption.prose.28.kms_connect_callback.test.ts Skips the callback timeout case.
src/​utils.ts Stops propagating timeoutMS and preserves write concern timeouts.
src/​timeout.ts Removes client-side timeout context creation from the factory.
src/​sessions.ts Removes session timeout inheritance and transaction deadline creation.
src/​operations/​run_command.ts Deprecates the command timeout option.
src/​operations/​operation.ts Deprecates the shared operation timeout option.
src/​operations/​command.ts Removes explain timeout conflict validation.
src/​mongo_client.ts Disables the timeout getter and updates timeout declarations and documentation.
src/​gridfs/​upload.ts Removes upload timeout context creation.
src/​gridfs/​index.ts Deprecates bucket timeout options.
src/​gridfs/​download.ts Removes download timeout context creation.
src/​explain.ts Removes the obsolete timeout conflict validator.
src/​db.ts Drops stored database timeouts and updates documentation.
src/​cursor/​run_command_cursor.ts Deprecates command cursor timeout options.
src/​cursor/​find_cursor.ts Removes find explain timeout conflict validation.
src/​cursor/​aggregation_cursor.ts Removes aggregation explain timeout conflict validation.
src/​cursor/​abstract_cursor.ts Removes cursor timeout propagation, validation, and close overrides.
src/​connection_string.ts Accepts and ignores timeoutMS with a deprecation warning.
src/​collection.ts Disables the timeout getter and updates documentation.
src/​client-side-encryption/​kms_options.ts Deprecates the callback timeout field.
src/​client-side-encryption/​client_encryption.ts Replaces timeout behavior documentation with a deprecation notice.
src/​change_stream.ts Removes change stream timeout context creation.

Review effort: Balanced

Comment thread src/mongo_client.ts
Comment thread src/connection_string.ts
Mark `timeoutMS` as deprecated and note its future removal.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@johnmtll johnmtll self-assigned this Oct 29, 2026
@johnmtll johnmtll added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Oct 29, 2026

@johnmtll johnmtll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In src/client-side-encryption/client_encryption.ts, we remove the description for timeoutMS entirely, in other files, we retain it (e.g: src/cursor/abstract_cursor.ts).

Can we maintain consistency by either keeping it or removing it everywhere it's deprecated?

Comment thread src/sessions.ts Outdated
Comment thread src/cursor/abstract_cursor.ts
@tadjik1
tadjik1 requested a review from johnmtll October 29, 2026 19:28
Comment thread src/cursor/abstract_cursor.ts
@johnmtll johnmtll removed the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Oct 30, 2026
@johnmtll johnmtll added the Team Review Needs review from team label Oct 30, 2026

@PavelSafronov PavelSafronov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@johnmtll
johnmtll merged commit 8345fe1 into main Oct 30, 2026
36 checks passed
@johnmtll
johnmtll deleted the NODE-7958 branch October 30, 2026 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Team Review Needs review from team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants