File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
internal-packages/run-engine/src/batch-queue Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -656,11 +656,16 @@ export class BatchQueue {
656656 const waitMs = Math . max ( 0 , ( result . resetAt ?? Date . now ( ) ) - Date . now ( ) ) ;
657657 if ( waitMs > 0 ) {
658658 await new Promise < void > ( ( resolve , reject ) => {
659- const timer = setTimeout ( resolve , waitMs ) ;
660659 const onAbort = ( ) => {
661660 clearTimeout ( timer ) ;
662661 reject ( this . abortController . signal . reason ) ;
663662 } ;
663+ const timer = setTimeout ( ( ) => {
664+ // Must remove listener when timeout fires, otherwise listeners accumulate
665+ // (the { once: true } option only removes on abort, not on timeout)
666+ this . abortController . signal . removeEventListener ( "abort" , onAbort ) ;
667+ resolve ( ) ;
668+ } , waitMs ) ;
664669 if ( this . abortController . signal . aborted ) {
665670 clearTimeout ( timer ) ;
666671 reject ( this . abortController . signal . reason ) ;
You can’t perform that action at this time.
0 commit comments