@@ -2,8 +2,8 @@ import { promisify } from 'util';
2
2
3
3
import type { BSONSerializeOptions , Document } from '../bson' ;
4
4
import type { MongoCredentials } from '../cmap/auth/mongo_credentials' ;
5
- import type { ConnectionEvents , DestroyOptions } from '../cmap/connection' ;
6
- import type { CloseOptions , ConnectionPoolEvents } from '../cmap/connection_pool' ;
5
+ import type { ConnectionEvents } from '../cmap/connection' ;
6
+ import type { ConnectionPoolEvents } from '../cmap/connection_pool' ;
7
7
import type { ClientMetadata } from '../cmap/handshake/client_metadata' ;
8
8
import { DEFAULT_OPTIONS , FEATURE_FLAGS } from '../connection_string' ;
9
9
import {
@@ -468,7 +468,8 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
468
468
selectServerOptions ,
469
469
( err , server ) => {
470
470
if ( err ) {
471
- return this . close ( { force : false } , ( ) => exitWithError ( err ) ) ;
471
+ this . close ( ) ;
472
+ exitWithError ( err ) ;
472
473
}
473
474
474
475
const skipPingOnConnect = this . s . options [ Symbol . for ( '@@mdb.skipPingOnConnect' ) ] === true ;
@@ -494,15 +495,13 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
494
495
}
495
496
496
497
/** Close this topology */
497
- close ( options ?: CloseOptions ) : void {
498
- options = options ?? { force : false } ;
499
-
498
+ close ( ) : void {
500
499
if ( this . s . state === STATE_CLOSED || this . s . state === STATE_CLOSING ) {
501
500
return ;
502
501
}
503
502
504
503
for ( const server of this . s . servers . values ( ) ) {
505
- destroyServer ( server , this , { force : ! ! options ?. force } ) ;
504
+ destroyServer ( server , this ) ;
506
505
}
507
506
508
507
this . s . servers . clear ( ) ;
@@ -766,30 +765,20 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
766
765
}
767
766
768
767
/** Destroys a server, and removes all event listeners from the instance */
769
- function destroyServer (
770
- server : Server ,
771
- topology : Topology ,
772
- options ?: DestroyOptions ,
773
- callback ?: Callback
774
- ) {
775
- options = options ?? { force : false } ;
768
+ function destroyServer ( server : Server , topology : Topology ) {
776
769
for ( const event of LOCAL_SERVER_EVENTS ) {
777
770
server . removeAllListeners ( event ) ;
778
771
}
779
772
780
- server . destroy ( options , ( ) => {
781
- topology . emitAndLog (
782
- Topology . SERVER_CLOSED ,
783
- new ServerClosedEvent ( topology . s . id , server . description . address )
784
- ) ;
773
+ server . destroy ( ) ;
774
+ topology . emitAndLog (
775
+ Topology . SERVER_CLOSED ,
776
+ new ServerClosedEvent ( topology . s . id , server . description . address )
777
+ ) ;
785
778
786
- for ( const event of SERVER_RELAY_EVENTS ) {
787
- server . removeAllListeners ( event ) ;
788
- }
789
- if ( typeof callback === 'function' ) {
790
- callback ( ) ;
791
- }
792
- } ) ;
779
+ for ( const event of SERVER_RELAY_EVENTS ) {
780
+ server . removeAllListeners ( event ) ;
781
+ }
793
782
}
794
783
795
784
/** Predicts the TopologyType from options */
0 commit comments