Skip to content

fix(status): cancel pending Gateway reads in status on Ctrl+C - #197909

Merged
obviyus merged 4 commits into
openclaw:mainfrom
mushuiyu886:fix/status-interrupt-cancel
Nov 13, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
mushuiyu886:fix/status-interrupt-cancel

Conversation

@mushuiyu886

@mushuiyu886 mushuiyu886 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw status did not pass its abort signal to the Gateway status and channels.status reads, so Ctrl-C or SIGTERM while one of those replies was pending left the read running: the CLI hung until the cleanup deadline force-killed it (exit 137), or the read timed out and the report printed late.

#197969 already covers the readiness wait and probe in the same command and stops status and status --json quietly when the scan fails only because of the interrupt. This change covers the reads after the probe.

Why This Change Was Made

The status read in the status scan, the channels.status read, the status --json projection read and the local fallback status read now take the command's abort signal, and their existing catch paths rethrow the abort before their usual fallback, so the scan ends through #197969's quiet interrupt path. Uninterrupted scans, unreachable-Gateway output, JSON shape and exit codes are unchanged. No new text.

Evidence

Built CLI in a secretless node:24.22.1 container, real openclaw gateway run behind a relay that answers readiness and the probe normally but holds the status or channels.status reply. Main twice, candidate twice. On main, status (SIGINT), status --json (SIGTERM) and status --deep with channels.status held (SIGINT and SIGTERM) all ended in exit 137 about 2 s after the signal. With this change they exit 130 or 143 within 0.1 s, close the held socket at the signal, and print only the existing interrupt line, nothing on stdout. A healthy Gateway, no listener, and uninterrupted held replies give the same output on both. The deep status scan test in src/commands/status.scan.test.ts now also interrupts the scan while the status or channels.status read is pending: both cases fail on main (the scan resolves) and pass here, at 0 net test lines. Details: #197909 (comment).

fix(status): stop the Gateway status reads when status is interrupted

openclaw status did not pass its abort signal to the Gateway status and
channels.status reads, so Ctrl-C left them running until the CLI cleanup
deadline force-killed the process, or until the reads timed out and a
degraded report printed late. The five scan reads now take the command
interrupt signal, matching the channels list fix in openclaw#197815 and the id
status fix in openclaw#197747; the catch paths rethrow the abort so the canonical
130 exit is kept instead of a late degraded report. Uninterrupted scans,
unreachable-Gateway fallbacks and JSON output are unchanged.
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S labels Nov 12, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Pass the command’s abort signal to four Gateway reads and preserve interruption through their fallback handlers.

Example: Press Ctrl+C while openclaw status awaits a held Gateway status reply.

  • Before: The CLI remains connected until forced termination with exit 137.
  • After: The connection closes promptly and the CLI exits 130 without a late report.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused cancellation wiring, sufficient shipped-CLI proof and committed behavioral regressions leave no actionable review findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The built CLI with a real Gateway and response-holding relay exercises interrupted status, JSON projection and deep channel reads, showing prompt socket closure and exits 130/143 with unchanged controls; the local fallback was explicitly unexercised, and the final revision changes tests only.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Interrupting status during a pending Gateway reply can leave the CLI waiting until forced termination.
Reason: The change extends established interruption behavior using existing owners, preserving ordinary status results and fallback behavior.

Merge readiness

✅ Ready for maintainer review

This PR fixes a remaining cancellation defect on current main; the previous regression-coverage request is resolved, and no actionable findings remain.

Priority: P2
Reviewed head: 00bf9d834b918082c4bed5697aebe12c1f2e3e89

Before merge

None.

Findings

None.

Agent review details

How this fits together

Status scans read Gateway status and channel facts through callGateway, then compose text or JSON reports within the command’s work scope.

flowchart TD
  A[Status CLI] --> B[Command work scope]
  B --> C[Status scan]
  C --> D[Gateway RPC client]
  D --> E[Gateway]
  B --> F[Abort signal]
  F --> D
  C --> G[Report or quiet interruption]
Loading

Technical review

Best possible solution:

Merge this focused reuse of the existing command cancellation and Gateway transport owners after required checks pass.

Do we have a high-confidence way to reproduce the issue?

Current-main source confirms the missing signals, and supplied base-versus-candidate CLI traces demonstrate the failure; this review ran no target code.

Is this the best way to solve the issue?

The smallest complete fix is to pass the existing command signal into the four reads and rethrow its reason before ordinary fallback handling, as this PR does.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 18c0598e10de.

Provenance checked

  • Gateway-backed JSON status and timeout fallback keeps the original intent (6d175b1: Consume Gateway-owned fleet facts before expensive local discovery while retaining offline diagnostics; the later cold-start repair preserves a shared deadline.)
  • Overview status and channel fallback handling keeps the original intent (72dcf94: Consolidate shared status reporting; later runtime-degradation changes project authoritative Gateway facts without losing unavailable-Gateway controls.)
  • Local status fallback and command interruption keeps the original intent (7cd1837: Cancel readiness and probe work and stop quietly on the command’s own abort reason, leaving later RPC cancellation for this PR.)
  • Status scan regression suite keeps the original intent (58b1860: Retain primary behavioral coverage while removing duplicate fixtures and assertions; this patch extends the existing case without net test growth.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 1b3f38e adds src/commands/status.scan.gateway.ts:56 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1b3f38e7e4ff; files: src/commands/status.scan.gateway.ts)
  • Masato Hoshino: Raw commit 7cd1837 adds src/commands/status.scan.shared.ts:101 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7cd1837be625; files: src/commands/status.scan.shared.ts)

PR surface

Source +25, Tests 0. Total +25 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 28 3 +25
Tests 1 46 46 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 74 49 +25

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Interrupted diagnostic reads can delay CLI exit until forced termination, with limited scope and no demonstrated data loss.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-12T20:57:17.338Z sha 38dd581 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-13T01:24:37.190Z sha 83b6837 :: needs changes before merge. :: none

Reviewed November 12, 2026, 8:41 PM ET / November 13, 2026, 01:41 UTC (Revision 3).

@obviyus

obviyus commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Proof on the built CLI (node openclaw.mjs status), node:24.22.1 container with no secrets, isolated state and config. Base is main 28d20f9 (includes #197969); candidate is 83b6837 (this head).

Stand-in Gateway: a real openclaw gateway run behind a small relay on the configured port. The relay forwards HTTP and WebSocket traffic unchanged, so readiness (/startupz, health) and the probe (system-presence) answer normally, but it never forwards the reply to one RPC: status or channels.status. The signal is sent 0.5 s after the relay logs the held reply. Main twice, candidate twice.

lane  run                       held reply        signal  exit  after signal (r1, r2)
base  status                    status            INT     137   2.1 s, 2.0 s   (cleanup deadline force-kill)
base  status --json             status            TERM    137   2.1 s, 2.2 s
base  status --deep             channels.status   INT     137   2.1 s, 2.0 s
base  status --deep             channels.status   TERM    137   2.0 s, 2.0 s
cand  status                    status            INT     130   0.1 s, 0.1 s
cand  status --json             status            TERM    143   0.0 s, 0.0 s
cand  status --deep             channels.status   INT     130   0.0 s, 0.1 s
cand  status --deep             channels.status   TERM    143   0.1 s, 0.1 s

stderr on both lanes, every interrupted run; stdout empty on both:
Command interrupted by SIGINT. Waiting for cleanup before exiting.   (SIGTERM for the TERM runs)

Relay log for the held socket, same run on each lane:

base  ws#3 HELD reply status 2:a1af9017-…   ws#3 client closed 1006 with held status   (2.6 s later, process killed)
cand  ws#3 HELD reply status 2:b6ca2f64-…   ws#3 client closed 1005 with held status   (0.5 s later, right at the signal)

Controls, base and candidate, both rounds (stdout and stderr identical after masking lane path, port, ids and numbers):

healthy relay           status / status --json / status --deep   exit 0   same report
no listener             status                                   exit 0   same "unreachable (connect ECONNREFUSED ...)" report
held status, no signal  status                                   exit 0   8.3 s, same report
held status, no signal  status --json                            exit 0   61.3 s, same JSON
held channels.status,   status --deep                            exit 1   61.4 s, same existing failure lines
  no signal

The only masked JSON differences are the install root (/work/base vs /work/cand) and, in one healthy round, the Gateway's timing-dependent worker load fields.

After merging main, this keeps only the reads #197969 did not cover: the status read in the status scan, the channels.status read, the status --json projection read, and the local fallback status read, which now reuses #197969's signal (the fallback only runs after an ambiguous probe failure, so these runs do not reach it). Dropped: the health, diagnostics and heartbeat reads after the scan (outside the scan's quiet interrupt path, so an abort there would print an error), the extra abort check at command start, and the added test, so tests are at 0 net lines. Checks in the container: oxlint and oxfmt clean on the three changed files; vitest run src/commands/status.scan.test.ts src/commands/status.scan.shared.test.ts src/commands/status-json-command.test.ts 32 passed.

@obviyus

obviyus commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Nov 13, 2026
@clawsweeper clawsweeper Bot removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 13, 2026
@obviyus

obviyus commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 13, 2026
@obviyus
obviyus merged commit 3111745 into openclaw:main Nov 13, 2026
131 of 135 checks passed
@obviyus

obviyus commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Landed in 3111745. Thanks @mushuiyu886.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…aw#197909)

fix(status): stop held Gateway status reads when openclaw status is interrupted

After openclaw#197969, openclaw status stopped its readiness wait and probe on interrupt, but the Gateway status and channels.status reads, the status --json projection read and the local fallback status read still ignored the command's abort signal. A Ctrl-C or SIGTERM while one of those replies was held left the command waiting until the cleanup deadline force-killed it with exit 137. Those reads now take the command's abort signal, so the existing quiet interrupt path from openclaw#197969 handles them. Healthy, unreachable and uninterrupted runs are unchanged. No new text.

Evidence: the built CLI in a secretless node:24.22.1 container against a real gateway run behind a relay that answers readiness and the probe normally but holds the status or channels.status reply, main twice and candidate twice. On main, status with SIGINT, status --json with SIGTERM and status --deep with channels.status held all ended in exit 137 about 2 s after the signal. With this change they exit 130 or 143 within 0.1 s, the held socket closes cleanly and only the existing interrupt line prints. Healthy, unreachable and uninterrupted held-reply runs give the same output on both. The existing deep status scan test becomes a three-case table whose held cases fail on main, at net 0 test lines. Details: openclaw#197909 (comment).

Thanks @mushuiyu886.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants