Skip to content

Commit

Permalink
fix: [#1447] Fixes bug where waitUntilComplete() is resolved to early…
Browse files Browse the repository at this point in the history
… when many microtasks are used
  • Loading branch information
capricorn86 committed May 29, 2024
1 parent f021a33 commit 8dd673d
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export default class AsyncTaskManager {
if (!this.runningTaskCount && !this.runningTimers.length && !this.runningImmediates.length) {
// In some cases, microtasks are used by transformed code and waitUntilComplete() is then resolved too early.
// To cater for this we use setTimeout() which has the lowest priority and will be executed last.
// "10ms" is an arbitrary value, but it seem to be enough when performing many manual tests.
this.waitUntilCompleteTimer = TIMER.setTimeout(() => {
this.waitUntilCompleteTimer = null;
if (
Expand All @@ -128,7 +129,7 @@ export default class AsyncTaskManager {
) {
this.resolveWhenComplete();
}
});
}, 10);
}
}
}
Expand Down

0 comments on commit 8dd673d

Please sign in to comment.