File tree 1 file changed +18
-7
lines changed
1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -227,14 +227,25 @@ export const subscribe = (trigger: Trigger): Subscription => {
227
227
228
228
outerActiveTask . abortController . abort ( ) ;
229
229
230
- const abortedTaskPromise = outerActiveTask . promise ;
230
+ log . debug (
231
+ '%s (%s): waiting for task to abort' ,
232
+ trigger . name ,
233
+ outerActiveTask . id ,
234
+ ) ;
235
+
236
+ if ( outerActiveTask . queued ) {
237
+ return undefined ;
238
+ }
231
239
232
- // Do not start a new task until the previous task has been
233
- // aborted and the shutdown routine has run to completion.
234
- await abortedTaskPromise ;
240
+ outerActiveTask . queued = true ;
235
241
236
- // eslint-disable-next-line require-atomic-updates
237
- outerActiveTask = null ;
242
+ try {
243
+ // Do not start a new task until the previous task has been
244
+ // aborted and the shutdown routine has run to completion.
245
+ await outerActiveTask . promise ;
246
+ } catch {
247
+ // nothing to do
248
+ }
238
249
} else {
239
250
if ( trigger . persistent ) {
240
251
log . warn (
@@ -287,7 +298,7 @@ export const subscribe = (trigger: Trigger): Subscription => {
287
298
taskId,
288
299
trigger,
289
300
} ) // eslint-disable-next-line promise/prefer-await-to-then
290
- . then ( ( ) => {
301
+ . finally ( ( ) => {
291
302
if ( taskId === outerActiveTask ?. id ) {
292
303
log . debug ( '%s (%s): completed task' , trigger . name , taskId ) ;
293
304
You can’t perform that action at this time.
0 commit comments