MongoOperationTimeoutError

Node.jsMongoDriverErrortimeoutperformance

The client-side operation timeout (timeoutMS) was exceeded before the operation completed

What is happening?

MongoOperationTimeoutError is part of the Client-Side Operation Timeout (CSOT) feature introduced in the Node.js driver 6.x. When timeoutMS is set, the driver enforces a total timeout for the entire operation including server selection, connection checkout, and server-side execution. This is different from maxTimeMS which only limits server-side execution time.

Common causes

  1. timeoutMS set too low for the operation
  2. Slow server selection due to topology issues
  3. Connection pool exhausted — waiting for available connection
  4. Slow query or aggregation pipeline on the server
  5. Server under heavy load

Diagnostic Steps

Related Jira Issues

NODE-7929Closed
Clean up the connection in case of CSOT timeout
h3. Use Case As a developer using timeoutMS, I want a connection to be closed when an operation times out after its command was already written, So that a later operation on that pooled connection never receives the earlier command's reply. h3. User Experience With timeoutMS set and a slow app-to-database link, a write that uses almost all of the time budget makes sendWire throw MongoOperationTimeoutError: Server roundtrip time is greater than the time remaining. The connection is not c
NODE-7536Backlog
Flaky: non-awaitData cursors [3]
[2026/04/14 17:22:43.038] 1 failing [2026/04/14 17:22:43.039] 1) CSOT driver tests [2026/04/14 17:22:43.039] Tailable cursors [2026/04/14 17:22:43.039] when in ITERATION mode [2026/04/14 17:22:43.039] non-awaitData cursors [2026/04/14 17:22:43.039] refreshes the timeout for subsequent getMores: [2026/04/14 17:22:43.039] MongoOperationTimeoutError: Timed out during socket read (149ms) [2026/04/14 17:22:43.039] at Connection.readMany (s
NODE-6703Backlog
Flaky: CSOT driver tests | Tailable cursors | getMores -> Timed out during socket read[10]
{code:java} [2025/01/31 16:12:26.693] 1) CSOT driver tests [2025/01/31 16:12:26.693] Tailable cursors [2025/01/31 16:12:26.693] when in ITERATION mode [2025/01/31 16:12:26.693] non-awaitData cursors [2025/01/31 16:12:26.693] refreshes the timeout for subsequent getMores: [2025/01/31 16:12:26.693] MongoOperationTimeoutError: Timed out during socket read (150ms) [2025/01/31 16:12:26.693] at Connection.readMany (Z:\data\mci\7e391cf7