File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -486,12 +486,15 @@ describe("TNS Workers", () => {
486486 const numWorkers = ( interop . sizeof ( interop . types . id ) == 4 ) ? 4 : 10 ;
487487 const timeout = DEFAULT_TIMEOUT_BEFORE_ASSERT * 3.5 ;
488488
489- let messageProducerTimeout = null ;
489+ let messageProducerTimeout = true ;
490490 let iteration = 0 ;
491491 const produceMessageInLoop = ( ) => {
492492 NSNotificationCenter . defaultCenter . postNotificationNameObjectUserInfo ( 'send-to-worker' , { iteration } , null ) ;
493493 iteration ++ ;
494- messageProducerTimeout = setTimeout ( produceMessageInLoop , 1 ) ;
494+ // Prevent against rescheduling after we've been stopped
495+ if ( messageProducerTimeout ) {
496+ messageProducerTimeout = setTimeout ( produceMessageInLoop , 1 ) ;
497+ }
495498 } ;
496499 produceMessageInLoop ( ) ;
497500
@@ -512,6 +515,8 @@ describe("TNS Workers", () => {
512515
513516 setTimeout ( ( ) => {
514517 clearTimeout ( messageProducerTimeout ) ;
518+ // Signal we've stopped to prevent against rescheduling by an already queued timer tick
519+ messageProducerTimeout = null ;
515520
516521 expect ( onStartEvents ) . toBeGreaterThan ( 0 , `At least 1 worker should have started in ${ timeout } ms` ) ;
517522 expect ( onCloseEvents ) . toBeGreaterThan ( 0 , `At least 1 worker should have finished in ${ timeout } ms` ) ;
You can’t perform that action at this time.
0 commit comments