{"id":"3a9aa3f571049f3b","repo":"mongodb/node-mongodb-native","slug":"unreachable-if-you-are-seeing-this-error-please","errorCode":null,"errorMessage":"Unreachable. If you are seeing this error, please file a ticket on the NODE driver project on Jira","messagePattern":"Unreachable\\. If you are seeing this error, please file a ticket on the NODE driver project on Jira","errorType":"exception","errorClass":"MongoRuntimeError","httpStatus":null,"severity":"error","filePath":"src/timeout.ts","lineNumber":272,"sourceCode":"        } else {\n          this._serverSelectionTimeout = null;\n        }\n      }\n    }\n\n    return this._serverSelectionTimeout;\n  }\n\n  get connectionCheckoutTimeout(): Timeout | null {\n    if (\n      typeof this._connectionCheckoutTimeout !== 'object' ||\n      this._connectionCheckoutTimeout?.cleared\n    ) {\n      if (typeof this._serverSelectionTimeout === 'object') {\n        // null or Timeout\n        this._connectionCheckoutTimeout = this._serverSelectionTimeout;\n      } else {\n        throw new MongoRuntimeError(\n          'Unreachable. If you are seeing this error, please file a ticket on the NODE driver project on Jira'\n        );\n      }\n    }\n    return this._connectionCheckoutTimeout;\n  }\n\n  get timeoutForSocketWrite(): Timeout | null {\n    const { remainingTimeMS } = this;\n    if (!Number.isFinite(remainingTimeMS)) return null;\n    if (remainingTimeMS > 0) return Timeout.expires(remainingTimeMS);\n    return Timeout.reject(new MongoOperationTimeoutError('Timed out before socket write'));\n  }\n\n  get timeoutForSocketRead(): Timeout | null {\n    const { remainingTimeMS } = this;\n    if (!Number.isFinite(remainingTimeMS)) return null;\n    if (remainingTimeMS > 0) return Timeout.expires(remainingTimeMS);","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/3366c21a6311e02f1be91da982f9b93d3cce99a0/src/timeout.ts#L254-L290","documentation":"Thrown by the @internal CSOTTimeoutContext.connectionCheckoutTimeout getter when _serverSelectionTimeout is not an object (null/undefined) at the time the checkout timeout is requested. The code's invariant is that server selection runs first and produces a timeout object that the checkout reuses; reaching this branch means that invariant was violated. It is a MongoRuntimeError explicitly labeled unreachable and asking for a Jira ticket.","triggerScenarios":"Driver-internal race or ordering bug where connectionCheckoutTimeout is accessed before serverSelectionTimeout has been computed, or after it was cleared to null. Not user-reachable through normal API use.","commonSituations":"Unusual CSOT + load-balancer or transaction pinning sequences; regressions after timeout-context refactors; concurrent access to a single TimeoutContext from multiple operations.","solutions":["Report it as a driver bug via the NODE project on Jira with the driver version, topology, timeoutMS, and a repro.","As a workaround, disable CSOT (drop timeoutMS) for the affected operation to avoid the CSOT code path.","Upgrade to the latest driver release where the ordering may have been fixed."],"exampleFix":"// No user-side code fix - this is a driver invariant violation.\n// Workaround: avoid the CSOT path.\n\n// before\nawait coll.find({}, { timeoutMS: 5000 }).toArray(); // triggers CSOT path\n\n// after (workaround)\nawait coll.find({}).toArray(); // legacy timeout path","handlingStrategy":"try-catch","validationCode":"// no user-side validation prevents this internal invariant violation;\n// work around by avoiding the CSOT path:\nawait coll.find({}).toArray(); // no timeoutMS -> legacy timeout path","typeGuard":null,"tryCatchPattern":"try {\n  await coll.find({}, { timeoutMS: 5000 }).toArray();\n} catch (e) {\n  if (e instanceof MongoRuntimeError && /Unreachable/.test(e.message)) {\n    // fall back to no-CSOT path and file a driver bug\n    await coll.find({}).toArray();\n  } else throw e;\n}","preventionTips":["Report occurrences to the NODE driver Jira with driver version and repro.","Update to the latest driver where ordering invariants may be fixed.","As a workaround, omit timeoutMS to avoid the CSOTTimeoutContext code path."],"tags":["timeout","csot","internal","runtime","unreachable","bug-report"],"analyzedSha":"3366c21a6311e02f1be91da982f9b93d3cce99a0","analyzedAt":"2026-08-04T13:40:15.335Z","schemaVersion":2}