Hub shutdown: drain in-flight requests then force-close lingering streams - #479
Conversation
|
Code-review pass on the two-phase drain. Linear checkboxes (CL-7210) verified against the code, not ticked on trust — all three genuinely met: server.stop() completes within the drain window with a live SSE/websocket connection (grace + force-close), that no longer reports a fault and exits non-zero on an ordinary deploy, and there's real test coverage (a real Bun.serve() with an open websocket, both phases). Comment-accuracy verdict on the disk-write claim: the mechanical claim is true, checked against Bun's own docs, not assumed. Fetched Bun's server.stop() reference directly: Timing coherence: was fine (grace 6s < overall bound 10s, force-close phase gets ~4s), but coherent timing wasn't sufficient — reachability is a genuine bug, now fixed. A write slow enough to still be running when the 6s grace window elapses (a large tarball, or a write queued behind another writer's per-repo lock) was still torn: the old code called Fix pushed (two commits):
New regression test in Verified locally, all foreground:
Not merging — leaving for CI and final review. |
da13203 to
60ce792
Compare
|
Holding this rather than fixing the
It edits vendored code. Every line of that delta is re-pin tax: it has to be hand-reapplied at each future pin (CL-7107), and it grows the vendored surface rather than shrinking what we re-create. It is also less correct than tracking requests directly. That
Suggested: drop the The rest of the PR (the bounded drain in |
60ce792 to
a132990
Compare
Summary
apps/hubcalledserver.stop()with no argument on shutdown, which waits for every open connection to close on its own — including a workbench SSE bridge and an idle sidecar websocket. Those never close by themselves, so the drain always timed out and the hub exited non-zero on any deploy with a live tab open.This replaces the previous approach (a vendored
hasPendingRepoWritesexport from@intx/hub-sessions, which only covered git-on-disk writes). Shutdown now:server.stop(true)so lingering SSE/websocket connections cannot hang the drain or fail it.A live stream at shutdown is not a drain fault.
Test plan
bun run typecheckinapps/hubbun testinapps/hub(in-flight tracker, drain helper, real Bun.serve SSE/websocket)bunx prettier --checkon touched hub filesgh pr checks)