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 {
263263 }
264264
265265 async _waitForPrimary ( timeout : number = 30000 ) : Promise < void > {
266+ let timeoutId : NodeJS . Timeout | undefined ;
266267 const timeoutPromise = new Promise ( ( resolve , reject ) => {
267- let id = setTimeout ( ( ) => {
268- clearTimeout ( id ) ;
268+ timeoutId = setTimeout ( ( ) => {
269269 reject ( 'Timed out in ' + timeout + 'ms. When waiting for primary.' ) ;
270270 } , timeout ) ;
271271 } ) ;
@@ -281,6 +281,10 @@ export default class MongoMemoryReplSet extends EventEmitter {
281281 timeoutPromise ,
282282 ] ) ;
283283
284+ if ( timeoutId != null ) {
285+ clearTimeout ( timeoutId ) ;
286+ }
287+
284288 this . debug ( '_waitForPrimary detected one primary instance ' ) ;
285289 }
286290}
You can’t perform that action at this time.
0 commit comments