Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The different of process.next() between MacOS and Linux #52756

Open
imaxue opened this issue Apr 30, 2024 · 0 comments
Open

The different of process.next() between MacOS and Linux #52756

imaxue opened this issue Apr 30, 2024 · 0 comments
Labels
linux Issues and PRs related to the Linux platform. macos Issues and PRs related to the macOS platform / OSX. promises Issues and PRs related to ECMAScript promises.

Comments

@imaxue
Copy link

imaxue commented Apr 30, 2024

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

@RedYetiDev RedYetiDev added macos Issues and PRs related to the macOS platform / OSX. promises Issues and PRs related to ECMAScript promises. linux Issues and PRs related to the Linux platform. labels Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linux Issues and PRs related to the Linux platform. macos Issues and PRs related to the macOS platform / OSX. promises Issues and PRs related to ECMAScript promises.
Projects
None yet
Development

No branches or pull requests

2 participants