Repository navigation
fix(platform): end itest /events tails and exit a truncated run - #4133
Conversation
The Backend integration job hung in lane 49 (checkBellHintWire) and then sat out its 30-minute step timeout with no tally (#4112). Root cause: the harness's outbound boundary (`routeVendorFetch`) built `new Request(input, init)` and handed that request to fetch. undici makes a request's signal follow the one it was built from through a weak reference to an AbortController that only that request holds, and nothing held the request once fetch had answered. A garbage collection between the /events response and the lane's abort dropped the link: the abort never reached the socket, the SSE body never ended, and the lane waited on `done` until the 10-minute lane deadline. The boundary now hands fetch the caller's own signal. The truncated run then hung in its teardown: a bare `server.close()` waits for every connection, and the stuck lane's tail never ends. The teardown now closes the backend with the deployment's `closeServerGracefully` and bounds every step (`settleTeardown`), so the tally prints and the run exits with its code. `connectSse` moves to the lane helpers with a bounded `close()` that cancels the body before it aborts, failing the lane within 5 s with the tail's name. checkBellHintWire closes its tails and deletes `p-bell-wire` in `finally` (#4077 item 5).
|
Exact-head CI at
|
An /events tail whose stream broke while its lane awaited something else (the backend dropped the connection mid-lane) rejected `done` with no handler attached, and Node's default ended the whole harness on the unhandled rejection: no lane named, no tally. `connectSse` now logs the failure as it happens and keeps it in `done`, named after the tail, for `close()` or the lane to throw; `close()` cancels only a tail that is still open. The teardown test waits for the tail's first heartbeat instead of a fixed 300 ms, and gives the step a wider bound. The boundary's comments say when the intermediate Request becomes collectable and what nodejs/undici#4627 changed.
|
Independent review of PR #4133 at
Runtime (mine; real PG 16.14 + pgvector, no pg_search)
I didn't re-run seam A (one Root cause 1 holds against undici 7.29.1. A LOW
INFO
Verified correct
CI at the exact head (merge ref
Merge: the next occurrence merges this exact head through the gate once the manager or the implementer confirms it is final, or reviews the delta if it changes. |
The Backend integration job hung in lane 49,
checkBellHintWire, five times in two days on unrelated PRs. After the 10-minute lane guard fired, it sat out the 30-minute step timeout with no tally. This fixes both defects at the root.Root cause 1: the lane's abort was lost to garbage collection
routeVendorFetch(integration-vendor-stub.ts) is the harness's outbound boundary, installed asglobalThis.fetchon 2026-10-01 (98d9965a2), the day before the first hang. It builtnew Request(input, init)and handed that request to fetch./eventsresponse andabort()dropped the link. The abort never reached the socket, the SSE body never ended, andawait mateStream.donewaited until the lane deadline.Lane 49 has the widest gap between a tail's response and its abort (sleep 700 + read-all +
waitFor), which is why it was always this lane.Fix: the boundary hands fetch the caller's own signal (
callerSignal), so fetch's kept-alive request follows it directly.Root cause 2: a truncated run never reached its tally
main()'sfinallyclosed the backend with a bareserver.close(), which waits for every open connection. The stuck lane's/eventstail never ends (15 s heartbeats).http-shutdown.test.tsalready pins that premise ("a bare server.close() parks while an /events stream is open").Fix: the teardown closes the backend with the deployment's own
closeServerGracefully, which ends every live stream and then force-closes what remains. Every teardown step is bounded (settleTeardown, 60 s each): a step that hangs or throws is recorded as a failed check naming it, and the harness still prints its tally and exits.Also
connectSsemoves tointegration-lane-helpers.tswith a boundedclose(). It cancels the body reader before it aborts, so the read ends on this side even if an abort never reaches the connection. If the tail still doesn't settle, the lane fails within 5 s withclosing the SSE tail /events?orgId=… did not settle within 5 s, not at the 10-minute guard. All six harness tails use it.checkBellHintWirecloses both tails and deletesp-bell-wireinfinally, which is Follow-ups from the #4056 review: a stale unread row after a withheld undo, per-recipient access rechecks, bell-lane cleanup, test gaps and Watch wording #4077 item 5. Its assertions are unchanged.withinDeadlineanderrorTextmove to the helpers, and deadlines under a minute now read in seconds.connectSse.Verification
Regression tests. Each fails on
mainand passes at this head.mainintegration-vendor-stub.test.ts› ends a streamed response on abort after a garbage collection, as fetch does (real SSE server + forced GC; plain fetch as the control)still open 2 s after the abort(the plain fetch:AbortError)integration-lane-helpers.test.ts›connectSse› ends a tail whose abort never reaches its connection; fails a close it cannot finish within the bound, naming the tailmain'sconnectSseis private tointegration-check.tsand has no bound. Its scenario onmainis seam A below, which hangs to the lane deadlineintegration-lane-helpers.test.ts›settleTeardown› names a step that never settles and still runs the next ones; closes the backend while a stuck lane's /events tail is still open (main's bare close is named as not settling, and the graceful close settles)main's teardown is inline and unbounded. Its scenario onmainis seam B below, which never prints a tallyProbe on CI's Node 22.21.1 (undici 6.22.0) and on Node 24.21.0 (undici 7.29.1):
fetch(url,{signal})+ GC + abort givesAbortError. The old boundary + GC + abort leaves the body still open. Without GC, both giveAbortError.Real harness, local (PG 16.14 + pgvector, no pg_search, so the BM25 boot check fails locally; Node 22.21.1;
ITEST_LANES=checkCollabEmitters,checkBellHintWire,checkBoardMoveEffects). The seams are uncommitted:gc()between the mate's bell hint and the abort.maina7efe1c51RUN TRUNCATED at lane 2 of 3 (checkBellHintWire) … did not settle within 10 min→ no tally; killed bytimeoutat 11:56:07 (exit 124)PASS personal bell hint wirein the same second →[itest] 20/21 checks passed across 3/3 lanes, 38 sRUN TRUNCATED→ no tally; killed at 12:01:32 (exit 124)RUN TRUNCATED … did not settle within 20 s→ 11:58:25[itest] RUN TRUNCATED at checkBellHintWire — 2/3 lanes ran+18/20 checks passed, exit 1Ten clean runs of the lane and its neighbours at this head (no seam, Node 22.21.1, a fresh database each): 10/10 have
PASS personal bell hint wireand the tally20/21 checks passed across 3/3 lanes, in 34–36 s each. The one failure in every run is the local BM25 boot check, which needspg_search.Gates run locally:
viteston the touched suites plus the two harness guards andhttp-shutdown.test.ts(52/52);oxlint --type-awareandoxfmt --checkon the changed files;tsc --noEmitover the changed files and their imports (exit 0); knip onservices/platform(no new finding).Closes #4112. Refs #4077 (item 5 only).