Skip to content

fix(status): Ctrl-C does not stop openclaw status during the Gateway probe - #197969

Merged
obviyus merged 6 commits into
openclaw:mainfrom
masatohoshino:fix/status-scan-interrupt
Nov 13, 2026
Merged

obviyus merged 6 commits into
openclaw:mainfrom
masatohoshino:fix/status-scan-interrupt

Conversation

@masatohoshino

@masatohoshino masatohoshino commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Closes #197968

What Problem This Solves

Fixes: Ctrl-C does not stop openclaw status or openclaw status --json while the Gateway probe waits on a Gateway that accepts connections but does not answer; the launcher force-kills the command about 2 seconds later (exit 137), and without the launcher the command keeps connecting for about a minute before it exits.

User Impact

User impact: Ctrl-C during the Gateway probe stops openclaw status (text and --json) within about a quarter of a second with the interrupt exit code (130, or 143 for SIGTERM) and only the existing stopping line, instead of a forced kill or another minute of Gateway connections.

Why This Change Was Made

The status scan's Gateway readiness wait and probe (resolveGatewayProbeSnapshot in src/commands/status.scan.shared.ts) did not take the command's abort signal, so an interrupt waited for the probe's own timeout. Both now take the ambient command signal, as #197758 passed it for sessions list. An interrupted probe resolves as "aborted"; the scan now stops right after the probe instead of rendering that result as Gateway state.

Evidence

Tested at this PR's head (base main fc6c25e9156).

Built CLI on Linux x64 with isolated state and config. The configured Gateway port is a stand-in TCP listener that accepts and never answers (an unresponsive Gateway). A PTY driver sends Ctrl-C 5 s after the CLI's first Gateway connection, which lands about 2 s into the probe connection, and records the exit code, the time from Ctrl-C to exit and each connection to the listener.

Before (base main fc6c25e9156):

status --json                          exit 137 (SIGKILL)  2031.3 ms after Ctrl-C, probe connection held until the kill
status                                 exit 137 (SIGKILL)  2039.9 ms after Ctrl-C, probe connection held until the kill
status --json, OPENCLAW_NO_RESPAWN=1   exit 130           55041.5 ms after Ctrl-C, probe connection held 28.0 s after Ctrl-C, 2 more Gateway connections after Ctrl-C

# status --json, output after Ctrl-C (launcher)
^CCommand interrupted by SIGINT. Waiting for cleanup before exiting.
<killed>

# status, output after Ctrl-C (launcher)
^CCommand interrupted by SIGINT. Waiting for cleanup before exiting.
■  Canceled
<killed>

# status --json with OPENCLAW_NO_RESPAWN=1, output 55 s after Ctrl-C
{
  "ok": false,
  "error": {
    "type": "cli_error",
    "message": "CLI stopping (SIGINT)"
  }
}
[openclaw] The CLI command failed.
[openclaw] For help, run `openclaw doctor`.

After (this PR): see the proof comment #197969 (comment). The interrupt exits 130 (SIGINT) or 143 (SIGTERM) about 0.1 s after the signal, with only Command interrupted by SIGINT. Waiting for cleanup before exiting. on stderr and nothing on stdout. status and status --json return quietly when the scan fails with the command's own abort reason; other scan failures keep their report.

Checks: pnpm test src/commands/status.scan.shared.test.ts --maxWorkers=1 (22 passed; the new test fails on base because the scan resolved instead of rejecting with the abort reason). The changed-file lint and the test-lines ratchet pass. The broad suites run in this PR's CI.

Local review: autoreview (Codex gpt-6.1-sol, high), base fc6c25e9156 to head 4fbbb6b8883, priority P0–P1: scoped-clean, no remaining findings.

Test file --maxWorkers=1 wall CI seconds
src/commands/status.scan.shared.test.ts 8.5 s (warm); 44.9 s on a cold first run 10.5 s (checks-node-changed, 11.8 s with setup)

Line deltas against main: production +34/-4 (status.scan.shared.ts, status-runtime-shared.ts, status.command.ts, status-json-command.ts); tests +19/-20 (the two no-fallback cases are folded into one table), no allocation file.

Not covered:

  • A Ctrl-C during the readiness wait (the first Gateway connection, about 3 s) was not driven; every run's Ctrl-C lands in the probe. The unit test mocks the readiness wait, so the signal on that call is covered by reading the source only.
  • The other Gateway reads in the status command take no signal here: the --json projection call, the overview's status and channels.status calls, the local status fallback, and status-runtime-shared.ts. fix(status): cancel pending Gateway reads in status on Ctrl+C #197909 changes those calls. A Ctrl-C that lands after the probe has returned, during one of them, is not changed by this PR and was not driven here.
  • In a scan that still has an earlier phase pending (the update check under --all, or a deep scan), an interrupted probe can reject before the scan awaits it. The CLI may then print [openclaw] Suppressed AbortError: ... on stderr; the exit is the same. This comes from reading the source and was not observed. It is accepted and not coded.
  • The update check and the Tailscale lookup in the same scan do not take the signal; both are bounded (the 10 s status timeout and 1.2 s).
  • Linux only.

openclaw status and status --json kept waiting on the Gateway readiness check and probe after Ctrl-C when the Gateway accepted connections but did not answer: the launcher force-killed the command after about 2 s (exit 137), or without it the command kept connecting for about a minute and then printed the CLI stopping error. The readiness wait and the probe now take the command's abort signal, and the scan stops once the probe returns after an interrupt.
@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: XS 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. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment 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

Passes the command abort signal through Gateway readiness and probing, then quietly ends interrupted text and JSON status scans.

Example: Press Ctrl-C during openclaw status while the configured Gateway accepts connections without answering.

  • Before: The launcher force-kills the command with exit 137 after its cleanup deadline.
  • After: The command exits promptly with code 130 without publishing a late status report.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct cancellation repair supported by shipped-CLI fault reproduction and normal-operation controls.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The supplied isolated Linux built-CLI trace exercises text SIGINT and JSON SIGTERM during the actual Gateway probe against an unresponsive listener, records prompt 130/143 exits without late reports, and includes unchanged healthy and failure controls; readiness-stage interruption was not separately exercised.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Ctrl-C acknowledges interruption but leaves a status probe running until timeout or forced termination.
Reason: Prompt cancellation restores the existing CLI lifecycle contract without adding configuration, public APIs, or persistent state.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a concrete cancellation bug still present on current main, with no introduced correctness or security findings.

Priority: P2
Reviewed head: 59d2e90b51d50c69aed23ebe8de599291ae7f2e3

Before merge

None.

Findings

None.

Agent review details

How this fits together

The status scan combines configuration and Gateway observations into text or JSON reports; its existing command lifecycle supplies cancellation and owns final cleanup.

flowchart TD
  A[Status CLI] --> B[Status scan]
  C[Command cancellation] --> B
  B --> D[Gateway readiness]
  B --> E[Gateway probe]
  D --> F[Gateway connection]
  E --> F
  B --> G[Text or JSON output]
Loading

Technical review

Best possible solution:

Use the existing command signal throughout the probe and stop report composition on owned cancellation while preserving unrelated failure diagnostics.

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

Current-main source omits cancellation at the reported readiness/probe calls, and the supplied built-CLI before/after trace demonstrates the resulting hang; no target code was executed during this review.

Is this the best way to solve the issue?

This is a focused root-cause repair using existing cancellation owners, with a shared interruption handler used by both affected output paths and a regression that rejects instead of returning an aborted snapshot.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6c32a15729f2.

Provenance checked

  • Gateway readiness and probe keeps the original intent (1b3f38e: Reuse the shared readiness owner and deadline to avoid false failures during cold starts.)
  • Status scan failure reporting changes intended behavior with a stated reason (2444509: Preserve independent installation-drift diagnostics when status collection fails; the PR explicitly exempts owned interruption while retaining other failure reports.)
  • Fallback regression cases keeps the original intent (b61485c: Keep dotted localhost excluded from local fallback and share the canonical loopback policy; the consolidated cases preserve both local and remote exclusions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +30, Tests -1. Total +29 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 34 4 +30
Tests 1 19 20 -1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 53 24 +29

Preflight source

Source stale. 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 proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: An interrupted diagnostic command can hang or require a forced kill when its Gateway does not answer; the impact is bounded to that command.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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-12T23:38:46.978Z sha 4fbbb6b :: needs maintainer review before merge. :: none
  • reviewed 2026-11-13T00:02:25.225Z sha 4fbbb6b :: needs maintainer review before merge. :: none

Reviewed November 12, 2026, 7:34 PM ET / November 13, 2026, 00:34 UTC (Revision 3).

@masatohoshino

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 12, 2026
@obviyus

obviyus commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Proof on the built CLI (node openclaw.mjs --profile ... status), node:24.22.1 container with no secrets, isolated state and config. The configured Gateway port is a local TCP listener that accepts connections and never answers. The signal is sent 4 s after start, during the probe. Base is main fc6c25e; candidate is 8cb9209 (the code at the pushed head 59d2e90, before formatting and the main merge).

lane  run                          signal  exit  seconds
base  status                       INT     137   6.1, 6.4   (launcher force-kill)
base  status --json                TERM    137   6.1, 6.3   (launcher force-kill)
cand  status                       INT     130   4.1, 4.1
cand  status --json                TERM    143   4.1, 4.2

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

The earlier head printed The CLI command failed. and a cli_error JSON envelope after that line. The status and status JSON commands now return quietly when the scan fails with the command's own abort reason; other scan failures keep their report.

Controls (base and candidate, stdout identical after masking profile, port, temp path and latency):

healthy Gateway (gateway run)        exit 0  2.9 s / 3.0 s   same report, Gateway reachable
no listener                          exit 0  1.6 s / 1.7 s   same "unreachable (connect ECONNREFUSED ...)" report
silent listener, not interrupted     exit 0  61.1 s / 61.2 s same "unreachable ... (ETIMEDOUT)" report

Checks in the container: vitest run src/commands/status.scan.shared.test.ts src/commands/status-json-command.test.ts 24 passed; oxlint and oxfmt clean on the changed files.

@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label 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. clawsweeper:intake:needs-environment 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: 👀 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: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 13, 2026
@obviyus
obviyus merged commit 7cd1837 into openclaw:main Nov 13, 2026
143 of 147 checks passed
@obviyus

obviyus commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Landed in 7cd1837. Thanks @masatohoshino.

obviyus added a commit that referenced this pull request Nov 13, 2026
fix(status): stop held Gateway status reads when openclaw status is interrupted

After #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 #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: #197909 (comment).

Thanks @mushuiyu886.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…probe (openclaw#197969)

fix(status): stop the Gateway probe when openclaw status is interrupted

openclaw status did not pass its abort signal to the Gateway readiness wait and probe, so Ctrl-C or SIGTERM against a Gateway that accepts connections but never answers was ignored until the launcher force-killed the command (exit 137), or the probe kept reconnecting for about a minute. Both calls now take the command's abort signal, and status and status --json stop quietly when the scan fails only because the command was interrupted; other scan failures are reported as before. status --all keeps its existing failure path. No new text.

Evidence: the built CLI in a secretless node:24.22.1 container against a local listener that accepts and never answers, main twice and candidate twice. On main, status with SIGINT and status --json with SIGTERM ended in exit 137 after about 6 s. With this change they exit 130 and 143 about 0.1 s after the signal and print only the existing interrupt line. A healthy Gateway, no listener and an uninterrupted run against the silent listener give the same output on both. The folded test is at -1 net test lines. Details: openclaw#197969 (comment).

Closes openclaw#197968. Thanks @masatohoshino.

Co-authored-by: Ayaan Zaidi <[email protected]>
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]>
obviyus added a commit that referenced this pull request Nov 14, 2026
fix(status): stop deep Gateway reads on Ctrl-C and SIGTERM

`openclaw status --deep`, `--json` and `--all` did not pass the command's abort signal to the deep Gateway reads (health, diagnostics.stability, last-heartbeat). A Ctrl-C or SIGTERM during a pending read did not stop it: the CLI waited until the cleanup deadline killed it. The signal now reaches those reads, and the interrupt is handled at the command boundary. Uninterrupted output and exit codes are unchanged. No new text.

Evidence: vitest-source, the regression has 2 failing abort cases on the merge base and passes here. Source tier with an isolated Gateway whose Telegram health probe targets an address that never answers, so the deep read naturally waits; each mode and signal twice per revision. Base exited 137 about 2 s after the signal (forced cleanup); this change exits 130 or 143 within 0.14-0.44 s with no late report. Uninterrupted runs print the same report and exit 0 on both; the earlier probe interrupt (#197969) still works. Full build with declarations and the packed CLI smoke pass. Net -3 test lines. Details: #198651 (comment).

Thanks @wangmiao0668000666.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 15, 2026
fix(status): stop deep Gateway reads on Ctrl-C and SIGTERM

`openclaw status --deep`, `--json` and `--all` did not pass the command's abort signal to the deep Gateway reads (health, diagnostics.stability, last-heartbeat). A Ctrl-C or SIGTERM during a pending read did not stop it: the CLI waited until the cleanup deadline killed it. The signal now reaches those reads, and the interrupt is handled at the command boundary. Uninterrupted output and exit codes are unchanged. No new text.

Evidence: vitest-source, the regression has 2 failing abort cases on the merge base and passes here. Source tier with an isolated Gateway whose Telegram health probe targets an address that never answers, so the deep read naturally waits; each mode and signal twice per revision. Base exited 137 about 2 s after the signal (forced cleanup); this change exits 130 or 143 within 0.14-0.44 s with no late report. Uninterrupted runs print the same report and exit 0 on both; the earlier probe interrupt (openclaw#197969) still works. Full build with declarations and the packed CLI smoke pass. Net -3 test lines. Details: openclaw#198651 (comment).

Thanks @wangmiao0668000666.

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: 🐚 platinum hermit Good normal PR readiness with ordinary 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.

openclaw status ignores Ctrl-C during the Gateway probe when the Gateway does not answer: forced kill after 2 s, or about a minute of connections

2 participants