-
Notifications
You must be signed in to change notification settings - Fork 298
Open
Labels
bugSomething isn't workingSomething isn't working
Description
The following code executes microtasks (promises are also microtasks) and then macrotasks (timeouts) on Chrome, Firefox and Safari.
setTimeout(() => console.lp("timeout #1 completed"), 0);
queueMicrotask(() => console.lp("microtask #1 completed"));
new Promise((resolve) => {
resolve();
}).then(() => console.lp("promise #1 resolved"));
setTimeout(() => console.lp("timeout #2 completed"), 0);
new Promise((resolve) =>
resolve();
}).then(() => console.lp("promise #2 resolved"));
queueMicrotask(() => console.lp("microtask #2 completed"));
queueMicrotask(() => console.lp("microtask #3 completed"));
setTimeout(() => console.lp("timeout #3 completed"), 0);Since we're using the same queue for the timeouts and microtasks, timeouts may executed in-between microtasks.
Edit: Seems promises are executed same as microtasks, they don't have higher prio than other microtasks. Changed it.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working