Skip to content

Commit

Permalink
Merge pull request #1449 from capricorn86/1447-waituntilcomplete-does…
Browse files Browse the repository at this point in the history
…nt-wait-long-enough-for-microtasks-to-complete-2

fix: [#1447] Fixes bug where waitUntilComplete() is resolved to early…
  • Loading branch information
capricorn86 authored May 29, 2024
2 parents f021a33 + 8dd673d commit fa03438
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 fa03438

Please sign in to comment.