Repository navigation
fix(cli): gateway usage-cost and stability print nothing after Ctrl+C - #197019
Conversation
|
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR cancels interrupted usage-cost and live stability reads and suppresses their late results. Example: Press Ctrl+C while openclaw gateway usage-cost --json awaits a delayed usage.cost response.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current cancellation bug and resolves the prior mutation-receipt finding; no actionable code findings remain. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway CLI actions translate command options into WebSocket RPC requests and render their responses; invocation cleanup supplies the cancellation signal. flowchart LR
A[CLI command] --> B[Diagnostic read action]
C[Invocation cancellation] --> B
B --> D[Gateway RPC transport]
D --> E[Gateway read handler]
E --> F[Response rendering]
C --> F
Technical reviewBest possible solution: Use the existing invocation signal for dedicated diagnostic reads while retaining generic Gateway write receipts. Do we have a high-confidence way to reproduce the issue? Current-main source confirms the missing signal and unconditional output, supported by the contributor's real CLI/Gateway traces and GoldArowana's independent signal-ordering reproduction; this review executed no target code. Is this the best way to solve the issue? The focused helper reuses existing cancellation and transport owners, checks both rejected and successfully settled requests, and avoids changing write-capable generic calls. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 45beb6735fe6. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +25, Tests -2. Total +23 across 2 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. 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 (3 earlier review cycles)
Reviewed November 11, 2026, 12:00 AM ET / 05:00 UTC (Revision 4). |
|
Candidate re-proof on e913431 (abort also checked after a successful reply), two runs: |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Committed regression in |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Exact-head re-proof on 4a51bb4 (built candidate, same harness). usage-cost and stability print nothing after Ctrl+C; call is unchanged on purpose; controls OK: |
|
Thanks for picking this up. I tested three additional cases on Node 24.22.1: Ctrl+C while usage-cost or stability is waiting for a reply, and a transport error arriving after the abort. All three fail on main and pass on this PR. Happy to share the test additions if useful. One question: the issue expects exit code 130 after Ctrl+C, but the PTY proof in the description shows exit=0. Is that down to how the harness sends SIGINT, or does the command's exit status change? |
|
Maintainer override: the only red is
Same test, same assertion today on other PRs (none of them change
Main, run locally (node 24.22.1 Linux container, clean install and build per commit, two runs each):
The local failures are not the CI assertion. They fail earlier: "Linux child ownership requires a process owner without source-loader hooks", then "fixture not ready", plus one 60 s timeout on current main. So the container can't show whether #196067 caused the CI failure, and it does not prove or rule out that commit. It does show the test fails on main without this PR. This PR changes only |
|
Landed in 3031a32. Thanks @GoldArowana for the report. |
…openclaw#197019) fix(gateway-cli): stop usage-cost and stability output after Ctrl+C openclaw gateway usage-cost and gateway stability sent their request without the command's abort signal and always printed the reply, so a Ctrl+C while the request was pending still printed the full result. Both now pass the existing signal, the same way gateway health does, and print nothing once aborted, including when a reply arrives after the abort. No text changes. gateway call is unchanged because it can run write methods, and hiding a reply after a change already happened would hide that change. Evidence: the built CLI on node:24.22.1 in a real PTY against a real built Gateway behind a WebSocket proxy that holds the reply for 1.5 s, two runs each. On main, Ctrl+C while pending still printed the full JSON for usage-cost and stability and the summary in text mode; with this change stdout stays empty. Uninterrupted runs, text output and gateway health match on both. The regression row in gateway-cli.coverage.test.ts fails on main, at -2 net test lines. The red run-loop.direct-stop-active-work.process.test.ts check is inherited: openclaw#197019 (comment). Fixes openclaw#197005. Thanks @GoldArowana for the report. Co-authored-by: Ayaan Zaidi <[email protected]>
Fixes #197005. Thanks @GoldArowana for the report.
Problem
If you press Ctrl+C while
openclaw gateway usage-cost --jsonis waiting on the Gateway, and the reply lands during cleanup, the CLI still prints the full JSON result.gateway stabilitybehaves the same way. (gateway calldoes too, but it can run write methods, so its receipt is left as is here.)gateway healthalready handles this: it passes the command's abort signal and prints nothing once it has been aborted.Fix
usage-costandstabilitynow use the same pattern ashealth. They pass the abort signal to the Gateway call and return without printing if the command was aborted. The shared helper is insrc/cli/gateway-cli/register.ts. No new text.Proof
Built CLI and built Gateway on node 24.22.1 in a secretless Docker container, run in a real PTY. A small WS proxy in front of the real Gateway holds the real
usage.cost/diagnostics.stabilityreply for 1.5 s. Ctrl+C goes through the terminal once the request is pending. I ran main twice and the candidate twice.usage-cost --json, Ctrl+Ccall usage.cost --json, Ctrl+Cstability --json, Ctrl+Cusage-cost(text), Ctrl+Cusage-cost --json, no Ctrl+CupdatedAt)usage-cost(text), no Ctrl+Chealth --json/healthEvery interrupted run printed the existing "Command interrupted by SIGINT" line on stderr. In this setup, both main and the candidate exited 0 after Ctrl+C, not the 130 the issue reports. This PR does not touch exit codes.
Regression:
src/cli/gateway-cli.coverage.test.tssends a reply after Ctrl+C. It fails on main and passes here. Focused tests:src/cli/gateway-cli.coverage.test.tsandsrc/cli/gateway-cli/register.option-collisions.test.tspass (45 tests). oxfmt and oxlint are clean.