File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -312,14 +312,16 @@ class Topology extends EventEmitter {
312312 }
313313
314314 options = options || { } ;
315- if ( this . s . state === STATE_CLOSED ) {
315+ if ( this . s . state === STATE_CLOSED || this . s . state === STATE_CLOSING ) {
316316 if ( typeof callback === 'function' ) {
317317 callback ( ) ;
318318 }
319319
320320 return ;
321321 }
322322
323+ stateTransition ( this , STATE_CLOSING ) ;
324+
323325 drainWaitQueue ( this [ kWaitQueue ] , new MongoError ( 'Topology closed' ) ) ;
324326 drainTimerQueue ( this . s . connectionTimers ) ;
325327
@@ -336,8 +338,6 @@ class Topology extends EventEmitter {
336338 delete this . s . detectTopologyDescriptionChange ;
337339 }
338340
339- stateTransition ( this , STATE_CLOSING ) ;
340-
341341 this . s . sessions . forEach ( session => session . endSession ( ) ) ;
342342 this . s . sessionPool . endAllPooledSessions ( ( ) => {
343343 eachAsync (
You can’t perform that action at this time.
0 commit comments