Repository navigation
fix(server): early requests get a 503 again instead of hanging until startup ends - #41627
juliusmarminge wants to merge 1 commit into
Conversation
…startup ends Since Effect 4.1.5, NodeHttpServer adds its own request listener before it listens. rejectRequestsUntilServing treated that as the serving handler and removed its 503, while the Effect fallback stays silent because other request listeners exist. Requests during startup then hung until serve() attached, so a client polling with a 1 s timeout only got through on a later retry. The handoff now starts only once the server is listening. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Problem
The server-metrics A/B of
v0.1.11(59651c1761f) againstmain(f58085a1c2e) flaggedstartup.readyMsas worse on both machines:Module loading, migrations and layer construction take about the same time on both sides; the server starts listening at about the same moment (~7.2 s after spawn on cups in both). The difference is what happens to a request after that. On
v0.1.11the firstGET /gets an immediate 503. Onmainit hangs untilserve()attaches the router about 2 s later, so a client polling with a 1 s timeout only gets through on a later retry.Cause
Effect 4.1.5 (#40132) changed
NodeHttpServer.maketo add its ownrequestlistener before it listens. That listener answers 503 only while it is the sole request listener.rejectRequestsUntilServingtreats any newrequestlistener as the serving handler and removes its own 503 handler. So Effect's listener removed ours, ours stopped answering, and Effect's stayed silent because the write-error and keep-alive listeners are still attached. Early requests and upgrades got no answer at all.Fix
The handoff in
rejectRequestsUntilServingstarts only once the server is listening, so onlyserve()takes over. The new test runs the guards through the realNodeHttpServer.make. Without the fix the early request hangs until the test times out.Before / after
node scripts/server-metrics.ts ab --only startup --rounds 3, beforef58085a1c2e, after this branch, cups (linux-x64). Another benchmark was running on the machine, which is why the absolute numbers are higher than the audit's:A probe run the same way as the harness on the same machine:
v0.1.11~9.6 s,main~12.6 s, this branch ~9.9 s. That puts this branch back at thev0.1.11level.Investigated and fixed by Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code