Repository navigation
Conversation
…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 (stablyai#25830, the root behind stablyai#15663/stablyai#23911/stablyai#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 stablyai#25830 Generated-by: GLM-5.3-Flash (ZCode)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe Unix socket transport now suspends its 30-second idle timeout while a dispatch is in flight. It restores the timeout after the last dispatch completes. Tests update Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Slow requests can retain their connection while quiet connections remain subject to the idle timeout. No identified issue prevents merging after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation
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 |
ELI5
If a local CLI request took longer than 30 seconds —
orca worktree createon a big repo, for example — Orca's runtime hung up mid-request. The worktree actually got created and the agent actually started, but the CLI was told "the runtime closed the connection, restart Orca". Callers (agents especially) then retried, which is how people ended up with orphaned worktrees or two agents working the same task. The hangup came from an idle timer that counts raw network silence — and a slow request is silent while it thinks. Now the timer pauses while a request is being processed and resumes when the socket is quiet again.What Changed
UnixSocketTransport(which serves both Unix sockets and Windows named pipes), the 30s reap timer is now suspended while any dispatch is in flight (socket.setTimeout(0)) and rearmed when the last dispatch cleans up. Verified against realnet.Socketsemantics:setTimeout(0)disables the timeout, and re-arming without a callback keeps the original one-time 'timeout' handler.runtime_unavailable/runtime_timeouterror surfaces, admission, and lifecycle are all untouched.Why
The idle timer's job is reaping dead peers, and it judged liveness by byte silence. A long-poll request never trips it because long-polls opt into keepalive frames — but ordinary slow handlers (
worktree.create,worktree.rm,browser.snapshot) send nothing while they work, so the timer read a healthy, thinking connection as a corpse. Suspending on in-flight dispatches fixes that at the mechanism itself. The alternative — auto-keepaliving every request — was rejected on evidence: an existing guard test (runtime-rpc-long-poll-transport.test.ts"does not emit keepalive frames for short RPCs") locks keepalive to long-polls as a deliberate invariant, and it would change the wire for every socket client. On a local socket a truly dead peer is delivered by the kernel as close/error, which the existing cleanup path already handles, so byte-silence reaping had no additional duty beyond idle reaping — and that duty is preserved.Linked Issue
Fixes #25830 (the server-side misreap — the report's root cause). Related symptom reports #15663 and #23911 and the #20108 orphan worktrees should stop occurring from this path; the report also sketches follow-ups (a distinct CLI error code for post-success connection loss, idempotent retries via
clientMutationId) that are deliberately not in this PR.Visual Proof
N/A — no UI change; the before/after is the socket lifetime, pinned by tests: before, a 45s non-long-poll dispatch was destroyed at 30s (
expected true to be falseon the socket-alive assertion); after, the reply arrives at 45s and the quiet socket reaps 30s later.Testing
Commands actually run locally (macOS): new cases red→green (1 failed / 6 passed before, 7 passed after — the FakeSocket was upgraded to model real idle-timer semantics: ms>0 counts, 0 suspends, re-arm keeps the original handler, traffic refreshes, destroy clears); transport/admission/framing suites including real-socket integration (3 files / 36 tests);
pnpm tcexit 0;oxlint/oxfmt --checkclean on both touched files. The named-pipe (Windows) branch shares all of this code but was not exercised on Windows; real 30s+ wall-clock behavior is simulated via the upgraded socket-model tests plus the real-socket integration suite, not a literal half-minute wait.AI Disclosure
Investigation, coding and verification by GLM-5.3-Flash (ZCode agent); orchestrated, reviewed and committed by a main agent with the same model, human overseeing.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Transport-internal change: no protocol or wire change, no new RPC, works identically for Unix sockets and Windows named pipes (same class), SSH unaffected (different transport, no such timer). Behavior after the fix: requests may now legitimately take arbitrarily long without the server hanging up — the CLI's own 60s
requestTimeoutMsremains the upper bound and reportsruntime_timeout(honest, unlike the previous "restart Orca" advice). Connection-reaping duty for genuinely dead peers is preserved and guard-tested.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)