Skip to content

fix(channels): cancel pending status reads on Ctrl+C - #196976

Merged
obviyus merged 3 commits into
openclaw:mainfrom
Alix-007:alix/fix-channels-status-interrupt-20261111
Nov 11, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
Alix-007:alix/fix-channels-status-interrupt-20261111

Conversation

@Alix-007

@Alix-007 Alix-007 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes channels status --probe being forcibly killed after an accepted Ctrl+C while its Gateway connection or status response is pending.

User Impact

Operators can interrupt the diagnostic promptly and get exit code 130, with its client connection closed and no late status JSON. Normal connection/authentication failures still show config-only status.

Why This Change Was Made

Carry the existing invocation cancellation signal through readiness and the read-only status RPC, then check it before publishing status or continuing fallback output. No config/default, protocol/schema, permission, migration or write-RPC policy changes.

Evidence

Product head: b19cbda9c01278b35058792153f160b028d2ea25.

The same normal-built openclaw.mjs channels status --probe --timeout 30000 --json 2>diagnostics.log command ran on BASE and HEAD with a controlling PTY, actual Ctrl+C and a compatible synthetic loopback WebSocket Gateway peer:

  • BASE: both interrupted phases acknowledged SIGINT but required startup-proxy SIGKILL after about 2.03 seconds.
  • HEAD: exit 130 after 136.53 ms, 109.82 ms; peer closure after 12.64 ms, 6.72 ms, before fixture cleanup. No late status/fallback JSON; the canonical cancellation-error JSON remains intact, and isolated config is unchanged.
  • Controls: two uninterrupted cases per revision returned exit 0 and the expected status JSON.

Frozen collector, stdout/stderr, peer events and replay instructions · HEAD receipt.

Focused validation: 14 tests across three affected suites; the unique fallback regression fails on BASE with nine controls passing. Scoped types, typed lint, normal commit hooks and the canonical test-line guard passed. Production +20/−2 lines; tests net −5 lines, with all original assertions retained and no budget allocation.

Scope, cleanup and inherited check limitation

The recorder boundary is the real CLI/client/socket against a synthetic peer, covering connect and pending channels.status. This does not claim a real Gateway service, hosted channel/provider, Windows/macOS or full repository CI. Secret/plugin work without an abort seam retains its own execution; final status publication is checked after it returns. All owned CLI/peer processes and threads exited; production configuration, sessions and channels were untouched.

BASE already exceeds the shared test-line ceiling by 7 LF (6,643,133 vs 6,643,126). This PR reduces test lines by five and removes its initial allocation; the canonical non-pruning guard passes without changing the shared scalar or granting unrelated debt credit. Cold compiled-worker attempts and their qualified identical-source replays are retained in the linked checks summary; final owner-worker preparation runs before test watchdogs, and no timeout or assertion was weakened.

@clawsweeper

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

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Pass the invocation cancellation signal through channel-status readiness, Gateway reads, and fallback rendering.

Example: Press Ctrl+C during openclaw channels status --probe --timeout 30000 --json while the status response is pending.

  • Before: The command acknowledges SIGINT but keeps its connection open until forced termination.
  • After: The command closes its connection, exits with code 130, and publishes no late status JSON.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused repair with shipped-entry-point evidence, preserved fallback contracts, and the previous finding resolved; CI completion remains pending.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The linked frozen receipts exercise the built CLI and real WebSocket client with actual PTY Ctrl+C during pending connect and status responses, demonstrating exit 130, socket closure before cleanup, and no late status output; obviyus additionally supplies built-Gateway startup and stalled-probe logs with successful controls. Production bytes are unchanged at the reviewed head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An accepted Ctrl+C can leave a channel-status diagnostic waiting until forced termination or allow it to print status afterward.
Reason: The patch restores expected interruption behavior using existing cancellation contracts and preserves successful diagnostics and ordinary config-only fallback.

Merge readiness

✅ Ready for maintainer review

This PR fixes a verified cancellation bug still present on current main. The prior mock-export finding is resolved, and no new correctness or security findings remain; current-head CI is still running.

Priority: P2
Reviewed head: 710e31dbde169024e15167568083694c1b993ed4

Before merge

None.

Findings

None.

Agent review details

How this fits together

The channels-status command turns CLI options into a read-only Gateway request, then renders status or a local config-only fallback; invocation cancellation must stop the read and prevent subsequent status publication.

flowchart TD
  A[CLI invocation] --> B[Channels status command]
  A --> C[Invocation cancellation signal]
  C --> B
  B --> D[Gateway readiness]
  B --> E[Gateway status read]
  E --> F[Status output]
  E --> G[Config-only fallback]
  C --> G
Loading

Technical review

Best possible solution:

Land the focused signal propagation and publication checks after the existing current-head CI gates pass.

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

Current-main source exposes the missing signal propagation, and inspected BASE/HEAD CLI receipts plus collaborator Gateway logs demonstrate the failure and repair; no target code was executed during this review.

Is this the best way to solve the issue?

This is the smallest complete repair: reuse invocation cancellation, readiness, and transport owners, and prevent late publication without changing generic RPC cancellation or normal fallback behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4b8fbc72a8b3.

Provenance checked

  • Gateway readiness and remaining diagnostic budget keeps the original intent (1b3f38e: Avoid false Gateway failures during cold starts by sharing readiness ownership and one remaining timeout budget.)
  • Gateway rejection versus transport fallback keeps the original intent (204b00b: Surface authoritative Gateway request errors while retaining config-only fallback for connection failures.)
  • Validated fallback configuration snapshot keeps the original intent (12863b8: Reuse the validated snapshot rather than rereading configuration during fallback.)
  • Status account fixture mock keeps the original intent (efb37f8: Narrow command-flow mocks around synthetic account snapshots; the updated factory retains those overrides and preserves other real exports.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Josh Avant: Raw commit f385491 adds src/commands/channels/status.ts:217 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: f385491c230c; files: src/commands/channels/status.ts)

PR surface

Source +18, Tests -4, Other -1. Total +13 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 20 2 +18
Tests 1 57 61 -4
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 4 77 64 +13

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.

Review metrics

Metric Value Why it matters
Production versus test LOC Production +20/−2; tests +57/−61 The production growth connects existing cancellation owners and guards asynchronous publication; the test changes retain existing contracts and add one distinct fallback-cancellation regression.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Interrupting a diagnostic can leave its client waiting until forced termination or produce late status output, with no demonstrated data loss or broken messaging workflow.
  • 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-11T02:22:32.882Z sha 7084eae :: needs maintainer review before merge. :: none
  • reviewed 2026-11-11T03:01:35.386Z sha b19cbda :: needs changes before merge. :: [P2] Preserve the mock-export ratchet when rewriting this factory

Reviewed November 10, 2026, 10:10 PM ET / November 11, 2026, 03:10 UTC (Revision 3).

@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Removed the extra test allocation by consolidating the owner tests. Focused tests, types, lint and the test-line guard pass; the body links fresh native proof for b19cbda9c012.

@clawsweeper

clawsweeper Bot commented Nov 11, 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-repro Preliminary submission classification; full source review pending. labels Nov 11, 2026
@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Maintainer proof for the production change at b19cbda9c012 (it matches 7084eae2; only tests changed since).

Setup: node 24.22.1 in a secretless container, built CLI (pnpm build, node openclaw.mjs) on main d957d05 and on main plus this PR's production diff. A real built Gateway runs with a Telegram account whose apiRoot points at a local fake Bot API. Once the Gateway is ready, that API accepts getMe and never answers, so the channels.status probe stays pending. Ctrl+C is a real 0x03 written to a PTY. Socket state comes from ss on the CLI's connection to :18789.

Run main this PR
Ctrl+C during the status read (x2) killed by SIGKILL after 2168 / 2173 ms; the Gateway socket stays open until the kill exit 130 after 37 / 42 ms; the socket closes 3 ms after Ctrl+C
Ctrl+C while the Gateway is still starting (x3, Gateway not ready) SIGKILL after 2194 / 2074 ms; in run 3 the CLI kept waiting, connected once the Gateway was up, and printed the full status JSON 1.8 s after Ctrl+C exit 130 after 37 / 37 / 37 ms; no status JSON
Uninterrupted --probe --json exit 0 exit 0, same JSON (timings masked)
Gateway not running config-only JSON, exit 0 identical
channels status --json (no probe) exit 0 exit 0, same JSON (timings masked)

After Ctrl+C, this PR prints only the existing CLI stopping (SIGINT) error envelope, never status or config-only output.

The new fallback cancellation test passes with this PR. On main's production code it fails (promise resolved "undefined" instead of rejecting).

Event log excerpts
== main-status-int-1
      1 ms  gateway spawned pid=8085
   5793 ms  gateway listening and telegram monitor polling
   6797 ms  fake Telegram API now stalls getMe (probe target accepts, never answers)
   6798 ms  cli spawned pid=8261 argv=channels status --probe --timeout 30000 --json
   8127 ms  cli sockets to :18789 at Ctrl+C: 1 gateway listening=True
   8127 ms    ss: 127.0.0.1:59854 -> 127.0.0.1:18789 users:(("openclaw",pid=8274,fd=22))
   8127 ms  sent Ctrl+C (0x03) to the PTY
  10295 ms  cli Gateway socket gone (+2168 ms after Ctrl+C)
  10295 ms  cli exited code=-9 (signal SIGKILL)
  10295 ms  Ctrl+C -> exit: 2168 ms
  10295 ms  output after Ctrl+C: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\r\n'
  10881 ms  cli sockets to :18789 after run: 0
== cand-status-int-1
      1 ms  gateway spawned pid=8450
  20929 ms  gateway listening and telegram monitor polling
  22019 ms  fake Telegram API now stalls getMe (probe target accepts, never answers)
  22020 ms  cli spawned pid=8692 argv=channels status --probe --timeout 30000 --json
  23413 ms  cli sockets to :18789 at Ctrl+C: 1 gateway listening=True
  23413 ms    ss: 127.0.0.1:48746 -> 127.0.0.1:18789 users:(("openclaw",pid=8710,fd=22))
  23413 ms  sent Ctrl+C (0x03) to the PTY
  23416 ms  cli Gateway socket gone (+3 ms after Ctrl+C)
  23450 ms  cli exited code=130 (exit)
  23450 ms  Ctrl+C -> exit: 37 ms
  23450 ms  output after Ctrl+C: '^CCommand interrupted by SIGINT. Waiting for cleanup before exiting.\r\n{\r\n  "ok": false,\r\n  "error": {\r\n    "type": "cli_error",\r\n    "message": "CLI stopping (SIGINT)"\r\n  }\r\n}\r\n[openclaw] The CLI command failed.\r\n[openclaw] For help, run `openclaw 
  24070 ms  cli sockets to :18789 after run: 0
== main-connect-int-3
      1 ms  gateway spawned pid=12775
   2388 ms  gateway holds its lock and is still starting (state.schema-preflight)
   2389 ms  cli spawned pid=12810 argv=channels status --probe --timeout 30000 --json
   4394 ms  gateway ready at Ctrl+C: False
   4396 ms  cli sockets to :18789 at Ctrl+C: 0 gateway listening=True
   4396 ms  sent Ctrl+C (0x03) to the PTY
   4398 ms  cli Gateway socket gone (+2 ms after Ctrl+C)
   6192 ms  cli exited code=130 (exit)
   6192 ms  Ctrl+C -> exit: 1796 ms
   6192 ms  output after Ctrl+C: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\r\n{\r\n  "ts": 1794365514599,\r\n  "channelOrder": [\r\n    "telegram"\r\n  ],\r\n  "channelLabels": {\r\n    "telegram": "Telegram"\r\n  },\r\n  "channelDetailLabels": {\r\n    "telegram": "Telegra
   6697 ms  cli sockets to :18789 after run: 0
== cand-connect-int-1
      1 ms  gateway spawned pid=12389
   2388 ms  gateway holds its lock and is still starting (state.schema-preflight)
   2389 ms  cli spawned pid=12424 argv=channels status --probe --timeout 30000 --json
   4410 ms  gateway ready at Ctrl+C: False
   4412 ms  cli sockets to :18789 at Ctrl+C: 0 gateway listening=False
   4412 ms  sent Ctrl+C (0x03) to the PTY
   4414 ms  cli Gateway socket gone (+2 ms after Ctrl+C)
   4449 ms  cli exited code=130 (exit)
   4449 ms  Ctrl+C -> exit: 37 ms
   4449 ms  output after Ctrl+C: '{\r\n  "ok": false,\r\n  "error": {\r\n    "type": "cli_error",\r\n    "message": "CLI stopping (SIGINT)"\r\n  }\r\n}\r\n[openclaw] The CLI command failed.\r\n[openclaw] For help, run `openclaw doctor`.\r\n\x1b[0m\x1b[?25h\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l
   5057 ms  cli sockets to :18789 after run: 0

@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 11, 2026
@Alix-007

Alix-007 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @obviyus for the real-Gateway checks, the mock-export fix, and landing this!

@obviyus
obviyus merged commit c719f9e into openclaw:main Nov 11, 2026
116 checks passed
@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Landed in c719f9e. Thanks @Alix-007.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 11, 2026
fix(channels): stop channels status --probe promptly on Ctrl+C

Pressing Ctrl+C during openclaw channels status --probe while the Gateway connection or status read was pending did not stop the command: it kept the Gateway socket open until it was force-killed about 2 seconds later, and could still print the status JSON. The command now forwards its existing abort signal into the existing readiness wait and status request. No text changes.

Evidence: the built CLI on node:24.22.1 in a real PTY against a real built Gateway with a local Telegram API stand-in that never answers the status probe. During the status read, main was killed after about 2.17 s with the socket open until then; with this change it exits 130 in 37-42 ms and the socket closes 3 ms after Ctrl+C. While the Gateway was still starting, main was killed after 2.07-2.19 s and once printed the full status JSON 1.8 s after Ctrl+C; this change exits 130 in 37 ms with no JSON. Uninterrupted --probe --json, an unreachable Gateway and channels status without --probe give the same JSON on both. The test mock now keeps the real module exports, so one stale entry leaves config/test-mock-exports-baseline.txt. Details: openclaw#196976 (comment).

Thanks @Alix-007.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 12, 2026
…197815)

fix(channels): stop the Gateway status read when channels list is interrupted

openclaw channels list did not pass its abort signal to the Gateway channel status read, so Ctrl-C or SIGTERM left the request running until the CLI's cleanup deadline force-killed the process, or until the read timed out and the fallback account list printed anyway. The status read now takes the command's abort signal, matching the channels status fix in #196976. Uninterrupted listings, the fallback list for an unreachable Gateway and channels status are unchanged. No new text.

Evidence: the built CLI in a secretless node:24.22.1 container against a real built Gateway with one Telegram account on a local fake Bot API, through a relay that holds the channels.status reply for 8 s. On main, SIGINT and SIGTERM during the status read were not cancelled and the cleanup deadline killed the process after about 2.2 s. With this change it exits 130 or 143 in about 0.13 s with no late list. Uninterrupted runs and an unreachable Gateway print the same accounts on both. The folded regression is at net 0 test lines. Details: #197815 (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 13, 2026
…penclaw#197815)

fix(channels): stop the Gateway status read when channels list is interrupted

openclaw channels list did not pass its abort signal to the Gateway channel status read, so Ctrl-C or SIGTERM left the request running until the CLI's cleanup deadline force-killed the process, or until the read timed out and the fallback account list printed anyway. The status read now takes the command's abort signal, matching the channels status fix in openclaw#196976. Uninterrupted listings, the fallback list for an unreachable Gateway and channels status are unchanged. No new text.

Evidence: the built CLI in a secretless node:24.22.1 container against a real built Gateway with one Telegram account on a local fake Bot API, through a relay that holds the channels.status reply for 8 s. On main, SIGINT and SIGTERM during the status read were not cancelled and the cleanup deadline killed the process after about 2.2 s. With this change it exits 130 or 143 in about 0.13 s with no late list. Uninterrupted runs and an unreachable Gateway print the same accounts on both. The folded regression is at net 0 test lines. Details: openclaw#197815 (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: 🦞 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