Repository navigation
round up timeout delay to avoid waking early - #61
Merged
Merged
Conversation
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>
This was referenced Nov 3, 2026
Merged
mbostock
added a commit
that referenced
this pull request
Nov 3, 2026
The timeout delay is now rounded up (#61), adding up to 2ms to the delays observed by the wake-time tests. Also restore the global setTimeout after each test, and pass --exit to mocha so that a failing test that leaves an active timer doesn't hang the run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mbostock
added a commit
that referenced
this pull request
Nov 3, 2026
* es bundle, pnpm Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * isolate tests from cached now() Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * allow for rounded-up timeout; don't hang on failure The timeout delay is now rounded up (#61), adding up to 2ms to the delays observed by the wake-time tests. Also restore the global setTimeout after each test, and pass --exit to mocha so that a failing test that leaves an active timer doesn't hang the run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * vitest, eslint 9 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * remove stale test/.eslintrc.json Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * eslint 10, vitest 5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * import it from vitest Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * eslint config Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * browser globals for src Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * d3-timer alias * 3.0.2 --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In Node,
setTimeoutis scheduled against libuv’s integer-millisecond loop clock and can fire a fraction of a millisecond beforeperformance.now()reaches the target time. When that happens,wakefinds 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 anow()cached by the previous test, is fixed in #58, which will be rebased onto this once merged. Supersedes #59.🤖 Generated with Claude Code