fix(cli): --wait-for-idle longer than 300 s works, as one request over node:http #2020
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2020"
general
weight: 0.35
openrig-review
What a person gets
rig send <seat> --wait-for-idle <seconds>works for any wait. Until now, a wait longer than 300 s failed at about 300 s as"Cannot connect to the OpenRig daemon … fetch failed (UND_ERR_HEADERS_TIMEOUT)", which reads as a daemon problem, and the text
wasn't sent. A long wait now behaves exactly like a short one, just longer: one wait, one deadline, and the daemon's own answer.
The cause
A waiting send's response starts only when its wait ends. Node's
fetch(undici) gives up on a response whose headers haven'tarrived within 300 s. The daemon isn't what cuts the request. In a Linux container on Node 22:
fetchagainst a server holding the response 320 s failed at 300.8 s withUND_ERR_HEADERS_TIMEOUT. That held for both a plainNode server and
@hono/node-server, which the daemon uses.node:http, which has no headers timeout, got the 200 at 320.0 s from the same@hono/node-server.0.7.0, 0.7.1 and main share this path byte for byte.
The change
packages/cli/src/long-request-fetch.ts: a small fetch overnode:httporhttps, for the subset the daemon client uses:method, headers, a string body and a signal.
- It returns the response when its headers arrive, as
fetchdoes, with the body read afterwards. So a connection lost afterthe daemon answered is the daemon client's existing "unreadable response (HTTP 200)" error, as on
fetch, never "The message wasnot sent."
- The request's own deadline stays a timeout, reached before or after the headers. Node's response stream, cut by our deadline
while a body is being read, ends with a plain "aborted" error. Once the request is aborted,
fetchWithTimeoutlets the abort'sreason decide. A body reset with no abort stays an unreadable response.
- Any other body is refused, rather than sent empty.
- It uses no global agent or proxy:
agent: false. A long request to an--hostreached only through a proxy that Node wastold to use would go direct.
DaemonClientsends a request allowed 300 s or more (FETCH_HEADERS_TIMEOUT_MS) through it. Everything around the request isunchanged: the seat header, the timeout and its message, caller aborts, connection-error codes and JSON handling. Shorter requests
still use
fetch.- Long
--wait-for-idlesends: the local send, the http-host send (--host) and MCPrig_sendall go throughDaemonClient.-
rig seat set-runtime: a runtime switch is allowed 300 s by default, and up to 3720 s with--confirm-timeout, so it usesthis path too. Its timeout still reads as outcome unknown.
- one deadline: nothing is sent after the time the person allowed;
- one binding to the seat's occupant: if the seat is replaced during the wait, the send is refused with
guard_target_changedand nothing is typed.
This PR's first version split a long wait into consecutive requests. That lost both guarantees, as review showed: a new request
could start after the whole wait had ended, and a replacement occupant could receive the text. That version is gone.
test/fetch-guard.ts) now covershttp.requestandhttps.requestwith the same rule it applies tofetch, so a test still can't reach a real daemon or another machine through the new path.No dependency, setting, route or daemon change.
Proof
All runs are in a Linux container: Node 22, tmux 3.3a, as root, with
--maxWorkers=2.A real wait at round 1's
9dc3323f:sleep 450.--wait-for-idle 400exited after 400 s with the daemon's own answer: "Target was still busy (foreground_command) when the400000ms wait ended (787 observations). No text was sent."
sleep 450.UND_ERR_HEADERS_TIMEOUT.Unit tests:
c4eb045a, these fail:- the one-request tests for the local send, the http-host send and MCP
rig_send;- the guard case;
- the new
long-request-fetchfile, which can't load its module yet.f875af24, these fail:- a body cut off after the headers reads as connection lost on the long path, where
fetchgivesDaemonResponseError(200);- a send over that path says "The message was not sent." after a delivery;
- a non-string body is sent empty.
2ab11a17: the body-stall test fails. On the long path, a deadline reached after theheaders read as an unreadable response, not a timeout.
60cd1d03:- the build passes;
- the 9 focused files pass 273 of 273:
send,mcp-server,cross-host-http,long-request-fetch,fetch-guard,client,client-headers,client-body-timeoutandfetch-with-timeout;- the whole CLI suite passes 5686, with 19 skipped and 2 failing;
-
test:repopasses 324 of 324.preflight"OpenRig home not writable" andscope-commands"current unreadable". They also fail on main inthis container, because root ignores the permission bits these tests depend on.
A terminal seat reports "running" or "unknown", never idle, so a send that lands after a long wait isn't shown end to end. The
daemon decides that the same way for any wait length.
🤖 Generated with Claude Code
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Bug Fixes
The CLI now handles send requests with wait times longer than five minutes without prematurely timing out while waiting for a response.
Long waits are sent in a single request, and daemon timeout errors are reported accurately.
Interrupted responses and aborted requests are handled more reliably, avoiding misleading messages that a message was not sent.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->