File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed
Expand file tree Collapse file tree 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 => {
227227
228228 outerActiveTask . abortController . abort ( ) ;
229229
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+ }
231239
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 ;
235241
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+ }
238249 } else {
239250 if ( trigger . persistent ) {
240251 log . warn (
@@ -287,7 +298,7 @@ export const subscribe = (trigger: Trigger): Subscription => {
287298 taskId,
288299 trigger,
289300 } ) // eslint-disable-next-line promise/prefer-await-to-then
290- . then ( ( ) => {
301+ . finally ( ( ) => {
291302 if ( taskId === outerActiveTask ?. id ) {
292303 log . debug ( '%s (%s): completed task' , trigger . name , taskId ) ;
293304
You can’t perform that action at this time.
0 commit comments