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 code example does not work as described #55582

Closed
slavamuravey opened this issue Oct 29, 2024 · 2 comments
Closed

The code example does not work as described #55582

slavamuravey opened this issue Oct 29, 2024 · 2 comments
Labels
doc Issues and PRs related to the documentations. duplicate Issues and PRs that are duplicates of other issues or PRs.

Comments

@slavamuravey
Copy link

slavamuravey commented Oct 29, 2024

Affected URL(s)

https://nodejs.org/docs/latest/api/process.html#when-to-use-queuemicrotask-vs-processnexttick

Description of the problem

  1. Open when-to-use-queuemicrotask-vs-processnexttick link.
  2. Look at the code example:

CJS

const { nextTick } = require('node:process');

Promise.resolve().then(() => console.log(2));
queueMicrotask(() => console.log(3));
nextTick(() => console.log(1));
// Output:
// 1
// 2
// 3

ESM

const { nextTick } = require('node:process');

Promise.resolve().then(() => console.log(2));
queueMicrotask(() => console.log(3));
nextTick(() => console.log(1));
// Output:
// 1
// 2
// 3

Expected:
For ESM the output should be:

// 2
// 3
// 1

Because ESM module is already a microtask.

Actual:
The output is identical for CJS and ESM.

@slavamuravey slavamuravey added the doc Issues and PRs related to the documentations. label Oct 29, 2024
@jakecastelli
Copy link
Member

Thanks for reporting the issue, this is a duplicate of #45048 and there is a stale PR - #45093

@avivkeller avivkeller closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2024
@avivkeller avivkeller added the duplicate Issues and PRs that are duplicates of other issues or PRs. label Oct 29, 2024
@slavamuravey
Copy link
Author

Ok, thank you, good to know it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. duplicate Issues and PRs that are duplicates of other issues or PRs.
Projects
None yet
Development

No branches or pull requests

3 participants