Closed
Description
Version
v23.3.0
Platform
Darwin mac.local 24.1.0 Darwin Kernel Version 24.1.0: Thu Oct 10 21:05:23 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6031 arm64
Subsystem
timers
What steps will reproduce the bug?
Run the following script:
const t = setTimeout(() => {
console.log("1");
}, 0);
clearImmediate(t);
await new Promise(resolve =>
setTimeout(() => {
console.log("2");
resolve();
}, 0),
);
await new Promise(resolve =>
setTimeout(() => {
console.log("3");
resolve();
}, 0),
);
How often does it reproduce? Is there a required condition?
Reproduces every time
What is the expected behavior? Why is that the expected behavior?
2
3
The first timeout should be cleared, and the second two should run because they were not cleared.
What do you see instead?
The last setTimeout
callback never runs:
$ node example.mjs
2
Warning: Detected unsettled top-level await at file:///Users/ben/example.mjs:11
await new Promise(resolve =>
^
$
Additional information
No response