Repository navigation
fix(daemon): release the diagnostics read stream when a caller hangs up - #5159
Conversation
Size Report
Startup median (7 runs, lower is better):
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on bdbc3a8. The verdict and the full list are in the summary comment.
bdbc3a8 to
cb9fc62
Compare
cb9fc62 to
778d7e1
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 778d7e1. The verdict and the full list are in the summary comment.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on d7baba3. The verdict and the full list are in the summary comment.
This comment has been minimized.
This comment has been minimized.
|
At 0c09e17, one abandoned diagnostics fetch can close the daemon if the record also fails to open. This ends every session, and it is a regression. The only early Could the base route stay as it was (response head, Not blocking: these can be taken or left: complete the held open after the hang-up and assert a closed fd on success and no These threads no longer apply and can be resolved: #5159 (comment) (the open wait now takes the disconnect signal; the missing listener after abort is covered above), #5159 (comment) (a first-read The required evidence is in place. All 22 checks pass at this commit. No test covers an open that fails after a hang-up, so the passing checks do not cover this problem. Not verified here: the Node 22.12 floor, since reproductions ran only on Node 26.11.1. The route and its two sibling modules were run in memory with stubbed authorize, path and error classes and a delayed Before merge, keep an |
An abandoned diagnostics fetch destroyed a record stream that was still opening with no `error` listener, so a failed open reached `uncaughtException` and closed the daemon. Restore the `pipe` route, whose listener lives from creation to close, and destroy the stream when the response finishes, errors or is abandoned. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
Re the review: fixed at 24e1a99 with the shape you suggested. The route is back to New tests cover an open that fails with Also checked on Node 22.12.0 and 26.11.1: real |
Apex Sentinel · ✅ Approve · review of
|
| Command | What it does |
|---|---|
@apex-sentinel-staging note <context> |
Adds context; Sentinel re-checks the cited code |
@apex-sentinel-staging pivot <why> |
Says the finding is wrong; Sentinel re-checks the cited code |
@apex-sentinel-staging like |
Marks the finding as useful |
@apex-sentinel-staging dislike <why> |
Marks it as not useful, so it is not raised again |
On this conversation, comment @apex-sentinel-staging review to run a full review once again.
|
At 24e1a99, the earlier problem is fixed: an abandoned diagnostics fetch with a failing record open can no longer close the daemon. These threads no longer apply and can be resolved: #5159 (comment) (the open wait is gone, and a hang-up destroys an opening stream), #5159 (comment) (a first-read The required evidence is in place. CI is green. One earlier Body rules run on this commit was cancelled, a later run succeeded, and that check does not exercise the changed route. Not verified here: no test or reproduction was run. Failure behavior on base and on the earlier commit comes from reading the code, and the new behavior comes from reading the code plus the passing CI unit run on Node 24.13.1. How |
Summary
GET /sessions/<session>/requests/<requestId>/diagnosticsstreams the record withstream.pipe(res), which only unpipes when the caller hangs up. The read stream stayed open and leaked its descriptor.The route keeps that shape and adds
finished(res, () => stream.destroy()): any response end, hang-up or error destroys the record stream. Theerrorlistener stays from creation to close, so an abandoned open that then fails cannot reachuncaughtExceptionand close the daemon.Before / after
Caller destroys its socket after 64 KiB of a 32 MiB record:
fdisnullCaller hangs up before the record opens:
EACCESis caughtStatus codes and response bytes are unchanged.
Validation
At
24e1a99795b7b611a17b25db0f675a6af9c42f24:createReadStream; the twoEACCEScases also fail on0c09e17with an uncaught exceptionEIO500, open-failure 500 and full download guard existing behaviourEACCESanswers 500 JSON, a later read error truncatestest/wire-compat: 51 passed;pnpm check:daemon-wire-compat, typecheck,oxlintandoxfmtcleanstream.destroy()without an error, which no route code calls, would leave the response openCI owns the full gate and device lanes.
🤖 Generated with Claude Code