Skip to content

Commit

Permalink
fix(topology): enter STATE_CLOSING before draining waitQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Feb 24, 2020
1 parent bf701d6 commit 494dffb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/core/sdam/topology.js
Expand Up @@ -312,14 +312,16 @@ class Topology extends EventEmitter {
}

options = options || {};
if (this.s.state === STATE_CLOSED) {
if (this.s.state === STATE_CLOSED || this.s.state === STATE_CLOSING) {
if (typeof callback === 'function') {
callback();
}

return;
}

stateTransition(this, STATE_CLOSING);

drainWaitQueue(this[kWaitQueue], new MongoError('Topology closed'));
drainTimerQueue(this.s.connectionTimers);

Expand All @@ -336,8 +338,6 @@ class Topology extends EventEmitter {
delete this.s.detectTopologyDescriptionChange;
}

stateTransition(this, STATE_CLOSING);

this.s.sessions.forEach(session => session.endSession());
this.s.sessionPool.endAllPooledSessions(() => {
eachAsync(
Expand Down

0 comments on commit 494dffb

Please sign in to comment.