Skip to content

feat(ipc): #85 abort in-flight handlers when the client disconnects — kill zombie commands - #1941

Merged
joelteply merged 1 commit into
canaryfrom
feat/ipc-abort-inflight-on-disconnect-85
Jul 8, 2026
Merged

joelteply merged 1 commit into
canaryfrom
feat/ipc-abort-inflight-on-disconnect-85

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Each IPC request is rt_handle.spawn'd detached and its JoinHandle dropped, so when the client disconnects
mid-flight the handler kept running to completion — writing its answer into a dead socket. A long blocking
command (a 60s ai/generate, a data scan) with no one left to answer is a zombie holding a lane + CPU.

Fix: the per-connection reader now tracks its spawned command handles (reaping finished ones so the Vec stays
bounded to what's actually in flight) and, on reader EOF (client gone), aborts any still-running handler —
aborting an already-finished task is a harmless no-op.

Composes with #86 by construction: a detached fire-and-poll job runs on its OWN tokio::spawn INSIDE the
handler, so the command task tracked here has already returned the job handle — there is nothing to abort for it.
Only abandoned BLOCKING requests are cancelled; long-running detached jobs survive the client leaving. Together
#85+#86 make a multi-hour acting eval both survivable (detach) and non-zombie-ing (abort the abandoned blocking case).

Co-Authored-By: Claude Opus 4.8 [email protected]
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

… kill zombie commands

Each IPC request is `rt_handle.spawn`'d detached and its JoinHandle dropped, so when the client disconnects
mid-flight the handler kept running to completion — writing its answer into a dead socket. A long blocking
command (a 60s ai/generate, a data scan) with no one left to answer is a zombie holding a lane + CPU.

Fix: the per-connection reader now tracks its spawned command handles (reaping finished ones so the Vec stays
bounded to what's actually in flight) and, on reader EOF (client gone), aborts any still-running handler —
aborting an already-finished task is a harmless no-op.

Composes with #86 by construction: a detached fire-and-poll job runs on its OWN `tokio::spawn` INSIDE the
handler, so the command task tracked here has already returned the job handle — there is nothing to abort for it.
Only abandoned BLOCKING requests are cancelled; long-running detached jobs survive the client leaving. Together
#85+#86 make a multi-hour acting eval both survivable (detach) and non-zombie-ing (abort the abandoned blocking case).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply merged commit 856a353 into canary Jul 8, 2026
1 check passed
@joelteply
joelteply deleted the feat/ipc-abort-inflight-on-disconnect-85 branch July 8, 2026 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant