Skip to content

Commit 077b94c

Browse files
committed
Optimizations
1 parent 36ba6f4 commit 077b94c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

JavaScript/2-timeouts.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ class Queue {
4646
if (this.waiting.length > 0) this.takeNext();
4747
};
4848
if (processTimeout !== Infinity) {
49-
const err = new Error('Process timed out');
50-
timer = setTimeout(finish, processTimeout, err, task);
49+
timer = setTimeout(() => {
50+
timer = null;
51+
const err = new Error('Process timed out');
52+
finish(err, task);
53+
}, processTimeout);
5154
}
5255
onProcess(task, finish);
5356
}

0 commit comments

Comments
 (0)