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

doc: fix process.nextTick() scheduling differences between module types #45093

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -2515,7 +2515,8 @@ The [`queueMicrotask()`][] API is an alternative to `process.nextTick()` that
also defers execution of a function using the same microtask queue used to
execute the then, catch, and finally handlers of resolved promises. Within
Node.js, every time the "next tick queue" is drained, the microtask queue
is drained immediately after.
is drained immediately after. Note that `process.nextTick()` is scheduled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process.nextTick is not scheduled differently, the module's execution is scheduled differently (specifically, it is a microtask). I think we should be careful of our wording here so people don't get confused.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. The wording here is a bit off. I would suggest wording like, "The timing of the execution of tasks scheduled with process.nextTick() will vary depending on the module type being used."

differently depending on the module type being used.

```mjs
import { nextTick } from 'node:process';
Expand All @@ -2524,9 +2525,9 @@ Promise.resolve().then(() => console.log(2));
queueMicrotask(() => console.log(3));
nextTick(() => console.log(1));
// Output:
// 1
// 2
// 3
// 1
```

```cjs
Expand Down