Skip to content

round up timeout delay to avoid waking early - #59

Closed
mbostock wants to merge 1 commit into
mbostock/rollupfrom
mbostock/timeout-ceil
Closed

mbostock wants to merge 1 commit into
mbostock/rollupfrom
mbostock/timeout-ceil

Conversation

@mbostock

@mbostock mbostock commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

In Node, setTimeout is scheduled against libuv’s integer-millisecond loop clock and can fire a fraction of a millisecond before performance.now() reaches the target time. When that happens, wake finds the timer isn’t yet due and waits another frame, so timers with delays over 24ms fire ~17ms late. This rounds the timeout delay up.

This is one of two causes of flaky tests under current Node (e.g. 66.58 should be in range of [40, 60]); the other, tests seeing a now() cached by the previous test, is fixed in #58, which will be rebased onto this once merged.

🤖 Generated with Claude Code

@mbostock mbostock mentioned this pull request Nov 3, 2026
@mbostock
mbostock added this pull request to stack #60 November 3, 2026 00:17
In Node, setTimeout is scheduled against libuv's integer-millisecond loop
clock and can fire a fraction of a millisecond before performance.now()
reaches the target time. The timer then isn't yet due, so it waits another
frame (17ms) before firing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mbostock

mbostock commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

Superseded by #61 (GitHub won’t retarget a stacked PR).

@mbostock mbostock closed this Nov 3, 2026
@mbostock
mbostock deleted the mbostock/timeout-ceil branch November 3, 2026 00:21
@mbostock
mbostock removed this pull request from stack #60 November 3, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant