File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -77,8 +77,10 @@ export function repeatingTask (fn: (options?: AbortOptions) => void | Promise<vo
7777 signal : shutdownController . signal
7878 }
7979
80+ let signal : ReturnType < typeof anySignal > | undefined
81+
8082 if ( options ?. timeout != null ) {
81- const signal = anySignal ( [ shutdownController . signal , AbortSignal . timeout ( options . timeout ) ] )
83+ signal = anySignal ( [ shutdownController . signal , AbortSignal . timeout ( options . timeout ) ] )
8284 setMaxListeners ( Infinity , signal )
8385
8486 opts . signal = signal
@@ -91,6 +93,17 @@ export function repeatingTask (fn: (options?: AbortOptions) => void | Promise<vo
9193 } )
9294 . catch ( ( ) => { } )
9395 . finally ( ( ) => {
96+ if ( signal != null ) {
97+ if ( signal . aborted ) {
98+ signal . clear ( )
99+ } else {
100+ // Clear listeners once this per-run signal eventually aborts
101+ signal . addEventListener ( 'abort' , ( ) => {
102+ signal . clear ( )
103+ } , { once : true } )
104+ }
105+ }
106+
94107 running = false
95108
96109 if ( shutdownController . signal . aborted ) {
You can’t perform that action at this time.
0 commit comments