Repository navigation
fix(cli): stop pending health reads when interrupted - #196655
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesConnect health CLI reads, readiness waits, and authentication diagnostics to the existing invocation cancellation signal. Example: Press Ctrl-C during a pending openclaw gateway health --json request with stderr redirected.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a distinct health-command cancellation bug still present on current main; the pinned diff has no actionable findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCLI registrations pass invocation cancellation through health commands into the existing Gateway transport and readiness owners, which return health output or settle interrupted reads. flowchart TD
A[CLI invocation] --> B[Health registrations]
B --> C[Health command]
C --> D[Readiness deadline]
C --> E[Gateway transport]
C --> F[Authentication diagnostic]
D --> G[Result or cancellation]
E --> G
F --> G
Technical reviewBest possible solution: Retain this focused wiring repair and merge through the normal required CI gates. Do we have a high-confidence way to reproduce the issue? Current-main source omits the cancellation signal, and supplied real-process before/after evidence reproduces the resulting forced termination; this review executed no target code. Is this the best way to solve the issue? The patch repairs the missing connection between invocation lifetime and existing read owners, preserving generic RPC behavior and callers without a signal. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0fd8c138f5bc. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +46, Tests -1. Total +45 across 8 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 10, 2026, 8:40 AM ET / 13:40 UTC (Revision 2). |
Forward the CLI cancel signal directly, treat any failure after an interrupt as silent, drop redundant pre-checks, and replace the allocation-backed tests with one regression.
|
Proof for head 02c4bc3, compared with main af37a00. Both were built CLIs ( Ctrl-C while a read is pending. The real Gateway was frozen with SIGSTOP. The kernel still accepts the TCP connection, so the health read hangs on its own. The CLI ran on a real pty with stderr redirected to a file. Ctrl-C (
On both trees stderr shows only Controls with a fully started Gateway and no interrupt. All of these matched main once timing fields are normalized:
Caller check. When it is interrupted, Doctor ( Changes on top of the contributor's commits.
Production is now +72/-26 against the merge base, and tests +12/-13. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Thanks @obviyus for the real-Gateway checks and landing the Ctrl-C fix! |
fix(cli): let Ctrl-C cancel pending health reads openclaw health and openclaw gateway health ignored Ctrl-C while the Gateway read was pending. The command kept its connection open until the launcher force-killed it about 2 s later. The health routes now pass the command's existing cancel signal to the Gateway read and exit quietly after an interrupt. Callers that pass no signal, including Doctor, configure, onboarding and status, behave as before, and no text is new. Evidence: the built CLI on node 24.22.1 in secretless Docker against a real Gateway frozen with SIGSTOP, with Ctrl-C sent through a real terminal 0.5 s after the connection opened and stderr redirected, two runs per command. On main, health and gateway health, with and without --json, hung until force-killed 2.06 to 3.56 s after Ctrl-C with the connection still open. With this change all four exit 130 in 0.03 to 0.43 s. Answered health checks, the unreachable-Gateway errors and doctor --non-interactive give the same output on both. Details: openclaw#196655 (comment). Thanks @Alix-007. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes: Ctrl-C during a pending
openclaw healthoropenclaw gateway healthread can leave its Gateway connection running until the launcher forcibly kills the process about two seconds later. This is reproducible when stderr is redirected, while the normal terminal interrupt is accepted.User Impact
Interrupted read-only health commands cancel their pending connection and exit promptly with 130, without publishing a late successful result. Normal health queries still work. Shared Doctor/onboarding callers and already dispatched nonhealth mutation receipts keep their existing behavior.
Why This Change Was Made
Explicitly connect the four health CLI registrations to the existing invocation signal and read transport/readiness deadline. Carry the same signal through the optional authentication diagnostic and check it before publishing results after asynchronous presentation work. Generic Gateway actions and other RPC calls receive no new default cancellation policy.
This is one complete health-read lifetime repair across seven existing production files (+110/-26), with six existing regression suites expanded (+208/-2, net 206 LF). The dedicated 206 LF allocation covers only the actual new test lines; the global baseline is untouched. No new dependency, public option, config/default, JSON schema/protocol, permission or upgrade/migration behavior.
Evidence
Product head
f5066a64003f67489e862003d647fbf7dc41bf9c; BASEbaccc7e152916c7f4a48596b5cb544c12264ac54. Both clean commits use their normalcliStartupbuild and actualopenclaw.mjsentry. The same frozen collector starts a real controlling PTY, redirects stderr to a regular file and sends real terminal Ctrl-C while the production Gateway client waits on a compatible synthetic loopback WebSocket peer:Set
EXPECT=redfor baseline andEXPECT=greenfor the product head, using fresh isolated output directories.Inspectable full BASE/HEAD terminal output, peer events, receipts, frozen collector and measured checks. Independent P0–P3 code/evidence review uses the authorized agent fallback; no official autoreview-helper result or hosted CI success is claimed.
Cleanup: owned CLI/peer processes and threads exit; isolated config hashes remain unchanged. No production Gateway/service/channel/provider or session is used. Not tested: native scenarios cover route-first JSON; full Commander text and authentication-fallback live transport are not natively replayed (focused owner tests cover those paths). Existing local presentation work without an abort seam is not newly made interruptible. Windows/macOS, real service lifecycle and upgrade completion remain untested.