Skip to content

doc: clarify setTimeout millisecond precision behavior#62468

Open
vijaygovindaraja wants to merge 1 commit intonodejs:mainfrom
vijaygovindaraja:doc/timers-millisecond-precision
Open

doc: clarify setTimeout millisecond precision behavior#62468
vijaygovindaraja wants to merge 1 commit intonodejs:mainfrom
vijaygovindaraja:doc/timers-millisecond-precision

Conversation

@vijaygovindaraja
Copy link
Copy Markdown

Timer delays are tracked with millisecond precision internally. When
measured with sub-millisecond clocks (process.hrtime(),
performance.now()), callbacks may appear to fire up to 1ms early
due to rounding at the millisecond boundary.

This has been a source of confusion for 7+ years (see #26578). Rather
than changing the timer implementation, this documents the existing
behavior so users understand the precision guarantee.

Approach discussed and endorsed by @apapirovski in #62466.

Refs: #26578

Document that timer delays are tracked with millisecond precision
internally, and that callbacks may appear to fire up to 1ms early
when measured with sub-millisecond clocks (process.hrtime(),
performance.now()). This is caused by rounding at the millisecond
boundary and is most noticeable when timers interact with
setImmediate() or other I/O.

Refs: nodejs#26578

Signed-off-by: V Govindarajan <vijay.govindarajan91@gmail.com>
@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout. labels Mar 27, 2026
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. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants