diff --git a/src/mongo_client.ts b/src/mongo_client.ts index 8f457cdb5a..d980f3e792 100644 --- a/src/mongo_client.ts +++ b/src/mongo_client.ts @@ -501,6 +501,9 @@ export class MongoClient extends TypedEventEmitter { Promise.all(activeSessionEnds) .then(() => { + if (this.topology == null) { + return; + } // If we would attempt to select a server and get nothing back we short circuit // to avoid the server selection timeout. const selector = readPreferenceServerSelector(ReadPreference.primaryPreferred);