Repository navigation
fix(react): deterministic fake clock for frameIntervalMs cases - #8
Merged
stamp-build[bot] merged 2 commits intoNov 21, 2026
Merged
Conversation
added 2 commits
November 21, 2026 08:09
ui.progress.filling failed on main 3 CSS px short of its golden (fill at
156 ms instead of 160 ms) while the same code passed on the PR run.
Cause: render.ts called page.clock.install({ time }) and then
page.clock.pauseAt(time + 1000) before navigating. Playwright replays these
calls into each new document using the real wall time at which each was
made, and the clock runs between install and pauseAt, so the page's
performance.now() started at the real milliseconds between the two calls
(0 on the recording run, 4 on main). The component mounted at that value
while requestAnimationFrame stays on 16 ms boundaries, so the last frame
before the capture was 4 ms less into the animation.
Call only pauseAt(clock): the new document starts paused at
performance.now() = 0 and Date.now() = clock, whatever the load takes. The
renderer now reads the page clock before the first settle frame (0) and at
the capture (settleFrames * frameIntervalMs) and makes the variant an error
on any other value. Documented in README and the meta type; unit tests for
the pure parts; CI verifies the frameIntervalMs cases 5 more times.
Signed-off-by: sindresorhus <raft+sindresorhus@agents.stamp.build>
The old golden was recorded with the page clock starting 1 ms late (fill 119 px, 159 ms in); the flaky main run started 5 ms late (116 px). With the clock starting at 0 the fill is 120 px: exactly 160 of 320 ms, half of the 240 px track, as the case's comment says. Recorded by CI run 44883277063. Signed-off-by: sindresorhus <raft+sindresorhus@agents.stamp.build>
stamp-build
Bot
force-pushed
the
agent/sindresorhus/react-clock-determinism
branch
from
November 21, 2026 08:09
c2e7694 to
038c76f
Compare
Merged
stamp-build Bot
added a commit
that referenced
this pull request
Nov 21, 2026
Deterministic fake clock for frameIntervalMs cases (#8) and local request routes (#6). Tagging v0.1.4 also exercises npm trusted publishing from the npm environment for the first time. Signed-off-by: sindresorhus <raft+sindresorhus@agents.stamp.build> Co-authored-by: sindresorhus <raft+sindresorhus@agents.stamp.build>
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.
main went red after merging (run 44882580287, job
react).ui.progress.filling@light,phonewas 3 CSS px short of its golden, which is 156 ms of the 320 ms fill instead of 160 ms. The same code had passed on the PR run.Root cause
For
frameIntervalMscases,render.tscalledpage.clock.install({ time })and thenpage.clock.pauseAt(time + 1000)beforepage.goto. Playwright (1.65.1,server/clock.tsandinjected/src/clock.ts) records each clock call as an init-script log entry, along with the host's realDate.now()at the moment of the call. Each new document injects the clock and callsresume(), then replays the log. During the replay, the clock runs in real time betweeninstallandpauseAt. So the navigated page'sperformance.now()starts at the real number of milliseconds between those two API calls, not at 0.The component mounts at
performance.now() = d. FakerequestAnimationFramestays on 16 ms boundaries of the fake clock, so after 10 x 16 ms the last frame is at 160 and the fill is(160 - d) / 320:I reproduced this with Playwright's own
ClockControllerin Node, driven by a fake embedder. Withinstall+pauseAtand a gap of 0/1/4/9 ms, the page starts atperformance.now()= 0/1/4/9. WithpauseAtalone it is 0 every time.Fix
page.clock.pauseAt(clock)is called before navigation. The page loads paused atperformance.now() = 0andDate.now() = clockhowever long load, network idle, readiness, fonts and images take. Settle frames thenrunFor(frameIntervalMs)in exact steps, so the capture is atsettleFrames * frameIntervalMs.Date.now()during load is nowclock, as it is for cases without a frame interval, instead ofclock + 1000. No golden depends on it.frameIntervalMsin the meta type.frameClockandclockProblemshave unit tests.verify, thereactjob runsvcase-react verify --filter 'ui.progress.*'5 more times, and any difference fails the job.Golden
ui.progress.filling@light,phonewas re-recorded by CI run 44883277063. The fill goes from 119 to 120 CSS px (measured: blue x 32..271 vs 32..269 at density 2), which is the documented instant: mount at 0, capture at 160 ms. No other golden and no manifest change. The first run on this PR passed both clock checks (0 before the first frame, 160 at capture) and failed only on this 1 px.🤖 Generated with Claude Code