Skip to content

Commit

Permalink
#1114@trivial: Fixes problem with clearing immediates in cancelAll().
Browse files Browse the repository at this point in the history
  • Loading branch information
capricorn86 committed Oct 4, 2023
1 parent d15b41f commit 28adfc7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/happy-dom/src/async-task-manager/AsyncTaskManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,25 @@ export default class AsyncTaskManager {
*/
public cancelAll(): void {
const runningTimers = this.runningTimers;
const runningImmediates = this.runningImmediates;
const runningTasks = this.runningTasks;

this.runningTasks = {};
this.runningTaskCount = 0;
this.runningImmediates = [];
this.runningTimers = [];

if (this.whenCompleteImmediate) {
global.clearImmediate(this.whenCompleteImmediate);
this.whenCompleteImmediate = null;
}

for (const timer of runningTimers) {
global.clearTimeout(timer);
for (const immediate of runningImmediates) {
global.clearImmediate(immediate);
}

for (const immediate of this.runningImmediates) {
global.clearImmediate(immediate);
for (const timer of runningTimers) {
global.clearTimeout(timer);
}

for (const key of Object.keys(runningTasks)) {
Expand Down

0 comments on commit 28adfc7

Please sign in to comment.