Skip to content

docs(asynchronous-work): clarify setImmediate() behavior#97

Merged
avivkeller merged 1 commit into
nodejs:mainfrom
raj-aayush01:docs/clarify-setimmediate-behavior
Jun 26, 2026
Merged

docs(asynchronous-work): clarify setImmediate() behavior#97
avivkeller merged 1 commit into
nodejs:mainfrom
raj-aayush01:docs/clarify-setimmediate-behavior

Conversation

@raj-aayush01

Copy link
Copy Markdown
Contributor

The documentation currently states that setImmediate() is equivalent to setTimeout(() => {}, 0).

This change clarifies that they are not generally equivalent because their callbacks execute in different phases of the event loop, and their execution order depends on the execution context.

Clarify that setImmediate() is not generally equivalent to setTimeout(() => {}, 0).

Signed-off-by: Aayush Raj <aayushraj065@gmail.com>
@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nodejs-learn Ready Ready Preview Jun 26, 2026 9:22am

Request Review

@cursor

cursor Bot commented Jun 26, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Documentation-only wording change with no runtime or API behavior impact.

Overview
Corrects the closing note on Node.js setImmediate() in Discover JavaScript Timers: it no longer claims equivalence to setTimeout(() => {}, 0).

The text now states that setImmediate() runs in the event loop check phase and that ordering versus zero-delay setTimeout depends on execution context, because the two APIs use different loop phases.

Reviewed by Cursor Bugbot for commit d2d3e27. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

Copy link
Copy Markdown

👋 Codeowner Review Request

The following codeowners have been identified for the changed files:

Team reviewers: @nodejs/timers

Please review the changes when you have a chance. Thank you! 🙏

@avivkeller avivkeller merged commit 3a8d092 into nodejs:main Jun 26, 2026
3 checks passed
@raj-aayush01 raj-aayush01 deleted the docs/clarify-setimmediate-behavior branch June 26, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants