node
node copied to clipboard
The different of process.next() between MacOS and Linux
Version
v20.10.0
Platform
MacOS and Linux
Subsystem
Ubuntu
What steps will reproduce the bug?
When I run this snippet of code, I got 1 2 4 3
on MacOS, but got 1 2 3 4
on Linux.
console.log("1");
process.nextTick(function () {
console.log("3");
});
new Promise(function (resolve) {
console.log("2");
resolve();
}).then(() => {
console.log("4");
});
If use setTimeout
wraps the snippet, it will be 1 2 3 4
on MacOS, like this:
setTimeout(() => {
console.log("1");
process.nextTick(function () {
console.log("3");
});
new Promise(function (resolve) {
console.log("2");
resolve();
}).then(() => {
console.log("4");
});
}, 0);
How often does it reproduce? Is there a required condition?
Every time
What is the expected behavior? Why is that the expected behavior?
It should be the same on MacOS and Linux
What do you see instead?
I got 1 2 4 3
on MacOS, but got 1 2 3 4
on Linux.
Additional information
No response