File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
packages/mongodb-memory-server-core/src Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -263,9 +263,9 @@ export default class MongoMemoryReplSet extends EventEmitter {
263
263
}
264
264
265
265
async _waitForPrimary ( timeout : number = 30000 ) : Promise < void > {
266
+ let timeoutId : NodeJS . Timeout | undefined ;
266
267
const timeoutPromise = new Promise ( ( resolve , reject ) => {
267
- let id = setTimeout ( ( ) => {
268
- clearTimeout ( id ) ;
268
+ timeoutId = setTimeout ( ( ) => {
269
269
reject ( 'Timed out in ' + timeout + 'ms. When waiting for primary.' ) ;
270
270
} , timeout ) ;
271
271
} ) ;
@@ -281,6 +281,10 @@ export default class MongoMemoryReplSet extends EventEmitter {
281
281
timeoutPromise ,
282
282
] ) ;
283
283
284
+ if ( timeoutId != null ) {
285
+ clearTimeout ( timeoutId ) ;
286
+ }
287
+
284
288
this . debug ( '_waitForPrimary detected one primary instance ' ) ;
285
289
}
286
290
}
You can’t perform that action at this time.
0 commit comments