Repository navigation
fix(runtime): keep a CLI socket open while its request is still running - #29262
Merged
Merged
Conversation
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
nwparker
force-pushed
the
nwparker/rpc-idle-timer-inflight
branch
from
October 16, 2026 03:43
f1cd3c1 to
4657280
Compare
…flight The runtime socket transport reaped connections after 30s of raw byte silence, and Node's idle timer counts bytes — so a slow dispatch like worktree.create on a large repo, which is not a long-poll and sends no keepalives, read as a dead peer: the server destroyed the socket mid- request, the handler kept running (the worktree got created), and the CLI reported runtime_unavailable and told the user to restart. Callers then retried, leaving orphaned worktrees or two agents on one task (#25830, the root behind #15663/#23911/#20108 symptoms). The reap timer now suspends while dispatches are pending and rearms when the last one cleans up. Quiet connections with nothing in flight still reap after exactly the same 30s, and a dead peer on a local socket is delivered by the kernel as close/error, which the existing cleanup already handles — so the reaping duty is unchanged where it mattered. Fixes #25830 Generated-by: GLM-5.3-Flash (ZCode)
nwparker
force-pushed
the
nwparker/rpc-idle-timer-inflight
branch
from
October 16, 2026 04:26
4657280 to
f70c435
Compare
This was referenced Oct 16, 2026
Closed
8 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When an
orcacommand took more than 30 seconds to answer (for exampleorca worktree createon a big repo), Orca hung up on the command halfway through. The command then said "the runtime closed the connection, restart Orca", even though Orca kept going and finished the job. Agents that saw the failure retried, which left orphaned worktrees or two agents working the same task. Now Orca stays on the line while it is still working on the request.What Changed
Before:
UnixSocketTransport(Unix sockets on macOS/Linux, named pipes on Windows) armedsocket.setTimeout(30_000, destroy)once per connection. Node's idle timer counts byte silence, and a slow request writes nothing while it works. Only long-poll methods send keepalive frames, soworktree.create,worktree.rm,browser.snapshotand other merely-slow requests were reaped at 30 s. The handler kept running and wrote its reply to a closed socket.After: while any request on a connection is still being handled, the idle timer is suspended (
socket.setTimeout(0)). When the last one replies (or the socket closes), the 30 s timer is armed again. A connection with nothing in flight is still reaped after exactly 30 s, as before.Why
worktree.createto the long-poll list: that list was already being patched one method at a time, and long-poll requests use admission slots. This fixes every slow request in one place.closehandler aborts the in-flight work. The idle reap was only meant for clients that connect and go quiet.This takes over #25889 by @ggbdpq (their commit, rebased on current
main). #22347 is the same approach and is superseded by this PR.Follow-ups not in this PR (from the issue): a distinct CLI error for "connection lost after the request was sent", and idempotent retries.
Linked Issue
Fixes #25830
Visual Proof
N/A. No UI change; this only changes when the CLI socket is closed.
Testing
pnpm test src/main/runtime/rpc/unix-socket-transport.test.ts:main(socket destroyed at 30 s).pnpm tc:nodeandpnpm run check:code-quality:changedpass.Notes
Cross-platform: the same transport serves Unix sockets and Windows named pipes;
setTimeout(0)behaves the same on both. No wire change, so mixed CLI and app versions are unaffected. SSH/remote runtimes use a different transport and are not touched.Checklist
N/Afor visual proof with reason