mongodb/node-mongodb-native · error · MongoRuntimeError
Unreachable. If you are seeing this error, please file a tic
Error message
Unreachable. If you are seeing this error, please file a ticket on the NODE driver project on Jira
What it means
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.
Source
Thrown at src/timeout.ts:272
} else {
this._serverSelectionTimeout = null;
}
}
}
return this._serverSelectionTimeout;
}
get connectionCheckoutTimeout(): Timeout | null {
if (
typeof this._connectionCheckoutTimeout !== 'object' ||
this._connectionCheckoutTimeout?.cleared
) {
if (typeof this._serverSelectionTimeout === 'object') {
// null or Timeout
this._connectionCheckoutTimeout = this._serverSelectionTimeout;
} else {
throw new MongoRuntimeError(
'Unreachable. If you are seeing this error, please file a ticket on the NODE driver project on Jira'
);
}
}
return this._connectionCheckoutTimeout;
}
get timeoutForSocketWrite(): Timeout | null {
const { remainingTimeMS } = this;
if (!Number.isFinite(remainingTimeMS)) return null;
if (remainingTimeMS > 0) return Timeout.expires(remainingTimeMS);
return Timeout.reject(new MongoOperationTimeoutError('Timed out before socket write'));
}
get timeoutForSocketRead(): Timeout | null {
const { remainingTimeMS } = this;
if (!Number.isFinite(remainingTimeMS)) return null;
if (remainingTimeMS > 0) return Timeout.expires(remainingTimeMS);View on GitHub (pinned to 3366c21a63)
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.
Example fix
// No user-side code fix - this is a driver invariant violation.
// Workaround: avoid the CSOT path.
// before
await coll.find({}, { timeoutMS: 5000 }).toArray(); // triggers CSOT path
// after (workaround)
await coll.find({}).toArray(); // legacy timeout path Defensive patterns
Strategy: try-catch
Validate before calling
// no user-side validation prevents this internal invariant violation;
// work around by avoiding the CSOT path:
await coll.find({}).toArray(); // no timeoutMS -> legacy timeout path Try / catch
try {
await coll.find({}, { timeoutMS: 5000 }).toArray();
} catch (e) {
if (e instanceof MongoRuntimeError && /Unreachable/.test(e.message)) {
// fall back to no-CSOT path and file a driver bug
await coll.find({}).toArray();
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Unusual CSOT + load-balancer or transaction pinning sequences; regressions after timeout-context refactors; concurrent access to a single TimeoutContext from multiple operations.
Related errors
- Unrecognized options
- Cannot create a Timeout with a negative duration
- Timed out
- KMS request timed out
- Unexpected HostAddress ${JSON.stringify(hostAddress)}
AI-assisted analysis of mongodb/node-mongodb-native@3366c21a63 (2026-08-04).
Data as JSON: /data/errors/3a9aa3f571049f3b.json.
Report an issue: GitHub.