Repository navigation
Commit 8b2ed00
test(web): deterministic artifact recorder — fixture generators on a stepped fake clock
Every server spec that writes a test/harness/__artifacts__ fixture now
renders through one recorder (test/server/artifact-recorder.ts) that
drives the render on a fake clock stepped 1 ms at a time — the fix #3849
applied to generic-hydration.gen.spec.tsx alone, for every artifact.
Why: the fixtures' flush points are timers and the stream coalesces one
event-loop turn into one chunk (`deferFlush`), so on real timers the
chunking and the script order are the host's. Reproduced on untouched
sources (full server suite, 3 runs, plus 20 targeted runs under 12 busy
loops on 10 cores): welcome-status-{loaded,streamed}.json re-recorded on
every run (the 5 ms usage/slot events vs the 15 ms `stats` promise, in
either order), write-before-resume.json split its one 60 ms chunk into
two on 3/23 runs (two timers created microseconds apart straddling a
millisecond), and nav-before-resume.json once wrote the 60 ms `<Side>`
fragment ahead of the route's 20 ms one.
On the stepped clock every fixture timer fires at its own instant in
creation order; timers due at the same instant flush together, distinct
instants flush separately. With the fixture built inside the recorded
render (welcome's `makeWelcome()` started its 15 ms timer at construction,
on the real clock), the recording is a function of the fixture: 10/10
full-suite runs under load, every artifact byte-identical.
Re-recorded: welcome-status-loaded.json and welcome-status-streamed.json
(shell unchanged; `rest` now carries the 5 ms usage trace events and the
slot chunk before the 15 ms stats value + fragment, the fixture's order —
the committed form was a loaded-host recording). The other ~150 artifacts
are byte-identical to what the recorder produces.
Guard: `writeArtifact` still re-records locally, but under CI (the
checkout IS the committed artifact) a recording that differs from the
committed file — or an artifact with no committed file — fails the test
with the first difference, instead of silently re-recording.
`JSX_COMPILER=babel` runs are an A/B and only write.
Tests / tooling only; no runtime change, no changeset.
Co-authored-by: Cursor <[email protected]>1 parent 8d23a5a commit 8b2ed00
18 files changed
Lines changed: 265 additions & 521 deletions
File tree
- packages/web/test
- harness/__artifacts__
- server
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
0 commit comments