This repository was archived by the owner on Feb 4, 2022. It is now read-only.
File tree 2 files changed +36
-1
lines changed
2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -951,7 +951,7 @@ Pool.prototype.destroy = function(force) {
951
951
while ( self . queue . length > 0 ) {
952
952
var workItem = self . queue . shift ( ) ;
953
953
if ( typeof workItem . cb === 'function' ) {
954
- workItem . cb ( null , new Error ( 'force flushing work queue ') ) ;
954
+ workItem . cb ( new MongoError ( 'Pool was force destroyed ') ) ;
955
955
}
956
956
}
957
957
Original file line number Diff line number Diff line change @@ -1148,4 +1148,39 @@ describe('Pool tests', function() {
1148
1148
pool . connect ( ) ;
1149
1149
}
1150
1150
} ) ;
1151
+
1152
+ it ( 'should properly emit errors on forced destroy' , {
1153
+ metadata : { requires : { topology : 'single' } } ,
1154
+
1155
+ test : function ( done ) {
1156
+ const pool = new Pool ( null , {
1157
+ host : this . configuration . host ,
1158
+ port : this . configuration . port ,
1159
+ bson : new Bson ( )
1160
+ } ) ;
1161
+
1162
+ pool . on ( 'connect' , ( ) => {
1163
+ var query = new Query (
1164
+ new Bson ( ) ,
1165
+ 'system.$cmd' ,
1166
+ { ismaster : true } ,
1167
+ { numberToSkip : 0 , numberToReturn : 1 }
1168
+ ) ;
1169
+
1170
+ pool . write ( query , function ( err , result ) {
1171
+ expect ( err ) . to . exist ;
1172
+ expect ( err ) . to . match ( / P o o l w a s f o r c e d e s t r o y e d / ) ;
1173
+ expect ( result ) . to . not . exist ;
1174
+
1175
+ expect ( Object . keys ( Connection . connections ( ) ) ) . to . have . length ( 0 ) ;
1176
+ Connection . disableConnectionAccounting ( ) ;
1177
+ done ( ) ;
1178
+ } ) ;
1179
+
1180
+ pool . destroy ( { force : true } ) ;
1181
+ } ) ;
1182
+
1183
+ pool . connect ( ) ;
1184
+ }
1185
+ } ) ;
1151
1186
} ) ;
You can’t perform that action at this time.
0 commit comments