You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f8bc60c
Browse filesBrowse the repository at this point in the historyBrowse files
fix(bench): make a run prove which build it measured
Closes#355.
`bench:matrix` printed `Error: Port 4173 is already in use` and then ran the
entire matrix against whatever was already there — another worktree's
`preview:bench` — writing ordinary-looking artifacts that described a different
branch's code. On #327 that inverted a conclusion for hours: post-fix runs kept
reporting `partial`, which read as "your fix did not work" rather than "you are
measuring someone else's build".
The hole is in `waitForServer`: it asks whether SOMETHING answers, and a foreign
server answers instantly. Nothing downstream ever asked *what* answered.
`vite build` now mints a fresh id, writes it to `dist/bench-build-id.txt`, and
injects the same value into the bundle, which publishes it on `<html>`. Two
independent checks read it:
- `bench-matrix.mjs` fetches the id from the server before running anything, so
a collision fails in the first second with the port to look at rather than
after a full matrix.
- `bench.spec.ts` compares the served id to `dist/` before it measures, so a run
driven any other way — directly, from an editor, with a hand-set BASE_URL —
gets the same protection.
A git SHA cannot do this job: the tree is dirty for most of a development loop,
so the SHA is identical across builds that differ. A per-build id answers the
question actually being asked, and catches a stale `dist/` and a forgotten
rebuild as well.
`PRETABLE_BENCH_SKIP_BUILD_CHECK=1` opts out when the target is deliberately not
a local build.
Verified against the live collision that motivated it — the other worktree's
server still holding 4173:
Error: http://127.0.0.1:4173 is not serving the build this checkout just produced
expected (dist/): 03f00ae1-…
served: (no id — an older build, or not a bench server)
Check `lsof -ti:4173`.
and no benchmark ran. The spec-level check was mutation-tested the same way, by
pointing it at a server serving a different id. A pre-check build reports no id
rather than its index.html, because the preview server falls back to that page
for anything it cannot find — only an id-shaped token counts as an answer.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
0 commit comments