@@ -321,11 +321,14 @@ process.on('multipleResolves', common.mustNotCall());
321321}
322322
323323{
324- async function runInterval ( fn , intervalTime , signal ) {
324+ async function runInterval ( fn , intervalTime , signal , emitter ) {
325325 const input = 'foobar' ;
326326 const interval = setInterval ( intervalTime , input , { signal } ) ;
327327 let iteration = 0 ;
328328 for await ( const value of interval ) {
329+ if ( emitter ) {
330+ emitter . emit ( 'myevent' ) ;
331+ }
329332 assert . strictEqual ( value , input ) ;
330333 iteration ++ ;
331334 await fn ( iteration ) ;
@@ -359,18 +362,21 @@ process.on('multipleResolves', common.mustNotCall());
359362 const delay = 10 ;
360363 let totalIterations = 0 ;
361364 const timeoutLoop = runInterval ( async ( iterationNumber ) => {
362- myEvent . emit ( 'myevent' ) ;
363- // The call to abort() will typically happen while we're awaiting here.
364- await setTimeout ( delay ) ;
365+ if ( iterationNumber <= 2 ) {
366+ assert . strictEqual ( signal . aborted , false ) ;
367+ }
365368 if ( iterationNumber === 2 ) {
366369 myEvent . once ( 'myevent' , ( ) => {
367370 controller . abort ( ) ;
368371 } ) ;
369372 }
373+ if ( iterationNumber > 2 ) {
374+ assert . strictEqual ( signal . aborted , true ) ;
375+ }
370376 if ( iterationNumber > totalIterations ) {
371377 totalIterations = iterationNumber ;
372378 }
373- } , delay , signal ) ;
379+ } , delay , signal , myEvent ) ;
374380
375381 timeoutLoop . catch ( common . mustCall ( ( ) => {
376382 assert . ok ( totalIterations >= 3 , `iterations was ${ totalIterations } < 3` ) ;
0 commit comments