Skip to content

Docs Incorrectly State setImmediate() Runs Before Timers #57993

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

Open
pakobarbakadze opened this issue Apr 23, 2025 · 2 comments · May be fixed by nodejs/nodejs.org#7677
Open

Docs Incorrectly State setImmediate() Runs Before Timers #57993

pakobarbakadze opened this issue Apr 23, 2025 · 2 comments · May be fixed by nodejs/nodejs.org#7677
Labels
doc Issues and PRs related to the documentations.

Comments

@pakobarbakadze
Copy link

pakobarbakadze commented Apr 23, 2025

Affected URL(s)

https://nodejs.org/en/learn/asynchronous-work/discover-promises-in-nodejs#advanced-promise-methods

Description of the problem

When to Use Each
Use queueMicrotask() for tasks that need to run immediately after the current script and before any I/O or timer callbacks, typically for Promise resolutions.
Use process.nextTick() for tasks that should execute before any I/O events, often useful for deferring operations or handling errors synchronously.
Use setImmediate() for tasks that should run after I/O events but before timers.

This line appears to be incorrect. According to the Node.js event loop phases, setImmediate() callbacks are executed during the check phase, which occurs after I/O callbacks and after timers have already been processed in the timers phase.

@pakobarbakadze pakobarbakadze added the doc Issues and PRs related to the documentations. label Apr 23, 2025
@avivkeller
Copy link
Member

Thank's for pointing that out! If you'd like to see a change in the learn articles, feel free to submit a PR to nodejs/nodejs.org.

@pakobarbakadze
Copy link
Author

Hello, @avivkeller. I have opened PR. Let me know if you'd like any adjustments!

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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants