Repository navigation
fix(scripts): server benchmark no longer fails when the server is slow to record its runtime state - #41574
Conversation
…w to record its runtime state Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
node scripts/server-metrics.ts ab --rounds 3 <v0.1.11> <main>failed today on Linux, macOS and Windows, each time on a different round and scenario, with:When that happens
abwrites no a.json/b.json, and the whole run (up to an hour) is lost.Cause. The harness waits only for the server's HTTP
/to answer, then runsproject add --base-dir. The server answers HTTP before it recordsuserdata/server-runtime.json:serverRuntimeStartup.ts:645waits for the HTTP listener, then runsprepareTrialand publishes the welcome event, and only reachesactivateat:670.layerRuntimeStatewaits for that activation and then publishes the runtime state (server.ts:955-978).RunningServer.changeStatefinds no live runtime state and makes the change locally.acquireServerOwnershipthen hits the lock the server took at startup (server.ts:923), and the command fails withServerAlreadyRunningError(exit 78).This ordering is the same on main (
server.ts,serverRuntimeStartup.tsandrunningServer.tspublish in the same order there). The failures landed on v0.1.11 only by timing, so B could have failed the same way.Fix. After the first HTTP answer, the harness also waits until
userdata/server-runtime.jsonexists, which is the point where the CLI starts talking to the running server. It uses the same wait budget as the HTTP wait, and if the file never appears it fails with the server's stderr.readyMsstill measures the first HTTP answer, so earlier results stay comparable. The file has been at that path since before v0.0.40, so old releases are covered too. I did not retry on exit 78: that would also hide a real second server holding the lock.No test: the change is a wait inside
startServer, and the script's tests cover only the pure report helpers. I did not run a full benchmark because the benchmark machines were busy.vp run check:changedpasses.Investigated and fixed by Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code