-
Notifications
You must be signed in to change notification settings - Fork 262
Closed
Labels
Description
Describe the bug
If you run this code on Node.js
setTimeout(() => {
console.log('First macrotask');
queueMicrotask(() => console.log('Add microtask from macrotask'));
queueMicrotask(() => console.log('Add microtask from macrotask'));
queueMicrotask(() => console.log('Add microtask from macrotask'));
}, 0);
setTimeout(() => {
console.log('Second macrotask');
}, 0);This is because Node original Event Loop runs:
- All microtasks
- 1 Macrotask
- All microtasks
Per loop.
And this is what happens when I run the same code on stackblitz:

It seems your Event Loop is running
- All microtasks
- All Macrotasks
- All Microtasks
Per loop.
Link to the blitz that caused the error
https://stackblitz.com/edit/node-4egzkj?file=index.js
Steps to reproduce
- Run node index.js
- See the wrong output
Expected behavior
Stackblitz should run 1 macrotasks, then all microtasks before running the next macrotask
Parity with Local
- I have run the project in my local machine and I could not reproduce the issue.
Screenshots
No response
Platform
- OS: [e.g. macOS, Windows, Linux]
- Browser: [e.g. Chrome, Safari, Firefox]
- Version: [e.g. 91.1]
Additional context
No response
alvarogfn, PauloHFS, arrudacaio, danielmelogpi, Franciscoflh and 9 more
