Skip to content

fix(channels): cancel pending status read in channels list on Ctrl+C - #197815

Merged
obviyus merged 2 commits into
openclaw:mainfrom
wangmiao0668000666:fix/channels-list-read-cancel
Nov 12, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
wangmiao0668000666:fix/channels-list-read-cancel

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw channels list issues the same channels.status RPC that channels status uses, but never passes an AbortSignal. When the user presses Ctrl+C while the gateway status read is pending, the RPC keeps running until its 5s timeout, delaying process exit and then printing a late command-local fallback account list on top of the cancelled output.

Why

channels status was already hardened for this in #196976 (thread getAsyncWorkSignal() through the RPC and re-raise cancellation). channels list calls the same RPC but was missed — a same-source call-site neighbor. Without a signal, callGateway has no abort handler, so the pending request is not cancelled and the CLI waits out the full timeout on Ctrl+C.

Solution

Thread the work-scope signal through the read, and re-raise the cancellation when the RPC settles after abort, instead of falling back to the command-local account list:

  • channelsListCommand captures getAsyncWorkSignal() and re-checks signal?.throwIfAborted() at the entry and after the gateway read.
  • readGatewayChannelStatus(signal) passes signal to callGateway, and on a caught error calls signal?.throwIfAborted() so a Ctrl+C surfaces as the canonical abort instead of an "unreachable gateway" fallback.

Evidence

Shipped CLI proof — real openclaw channels list executed from source trees (/ws-base vs /ws-head-channels-list) inside an isolated container, driven against a synthetic loopback WebSocket gateway peer speaking the real OpenClaw wire protocol. SIGINT is delivered to the PTY while the channels.status request is held pending (peer delays its response past the interrupt). Capture below is the machine-readable peer transcript produced by the harness (ws-peer-harness/drive.mjs), redacted (token shown as ***).

base (before) — late fallback printed after Ctrl+C

exitCode: 130, sigintToExitMs: 765
targetRequestSeen: true, method: channels.status
lateResponseSent: true, lateResponsePrinted: true

stdout:
Chat channels:
- Discord default (L8E_MARKER_7f3a91): installed, configured, enabled, token=***

stderr:
... Command interrupted by SIGINT. Waiting for cleanup before exiting.

peerEvents:
  listening -> connect(role=operator, scopes=[operator.read]) -> req channels.status {probe:false, timeoutMs:5000}
  -> held -> released {socketOpen:true}

head (fix) — no late output; cancelled promptly

exitCode: 130, sigintToExitMs: 461
targetRequestSeen: true, method: channels.status
lateResponseSent: true, lateResponsePrinted: false

stdout:
<empty>

stderr:
... Command interrupted by SIGINT. Waiting for cleanup before exiting.
[openclaw] The CLI command failed.

peerEvents:
  listening -> connect(role=operator, scopes=[operator.read]) -> req channels.status {probe:false, timeoutMs:5000}
  -> held            (request never released; process exits without printing the fallback)

The decisive difference: base shows held -> released {socketOpen:true} and prints the marker list after SIGINT; head stops at held and prints nothing — the pending read is cancelled and the cancellation propagates instead of the late fallback.

Discriminative unit test added (propagates cancellation during a pending gateway status read): red on base (promise resolves instead of rejecting with the cancel reason), green on head.

Precedent: #196976

Maintainer proof: #197815 (comment)

`channels list` issues the same `channels.status` RPC as `channels status`,
but never passed an AbortSignal. A Ctrl+C during the pending gateway read left
the request running until its 5s timeout, delaying exit and printing a
late command-local fallback list. Thread `getAsyncWorkSignal()` through the
read and surface the cancellation instead of the fallback.

Precedent: openclaw#196976 (same RPC fixed for `channels status`).

Co-Authored-By: nebulacoder-v8.0 <[email protected]>
@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 triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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

Passes invocation cancellation into channel-list status reads and propagates interruption instead of continuing to fallback output.

Example: Press Ctrl+C while openclaw channels list awaits a delayed channels.status response.

  • Before: The supplied built-CLI reproduction requires forced termination after the cleanup deadline.
  • After: The command cancels the read and exits normally with signal exit code 130.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused repair with shipped-entry-point cancellation proof, a reported red/green regression, and no open findings; final CI remains pending.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): Current-head collaborator logs exercise the built channel-list CLI against a real Gateway through a reply-delaying relay, demonstrate correct SIGINT and SIGTERM exits, and preserve normal, timeout, offline, JSON, and sibling-command controls.
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 interrupted channel-list status read continues waiting instead of allowing normal signal-driven exit.
Reason: Restores the established CLI cancellation contract without adding options, persistent state, or another lifecycle owner.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current-main cancellation gap with a focused patch and convincing built-CLI proof; no actionable defects were found, and CI remains pending.

Priority: P2
Reviewed head: f70e31a9703014dc01f457453400fd5ea5b18135

Before merge

None.

Findings

None.

Agent review details

How this fits together

The channel-list CLI combines plugin metadata and local configuration with Gateway account snapshots, then renders text or a local JSON inventory.

flowchart LR
  A[CLI invocation] --> B[Channel list command]
  C[Invocation cancellation] --> B
  B --> D[Gateway RPC client]
  D --> E[Gateway channel status]
  B --> F[Local account inventory]
  E --> G[Terminal output]
  F --> G
Loading

Technical review

Best possible solution:

Land the existing signal propagation and cancellation regression once the required exact-head checks pass.

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

Current-main source exposes the missing signal, and supplied base-versus-head built-CLI logs demonstrate the interruption failure; no target code was executed during this review.

Is this the best way to solve the issue?

The patch repairs the missing call-site connection to existing cancellation ownership while retaining normal Gateway fallback and JSON behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 808c53a7a763.

Provenance checked

  • Gateway-preferred account snapshots and unavailable-Gateway fallback keeps the original intent (b672be5: Prefer reachable Gateway account facts in text output while preserving local fallback and local JSON inventory.)
  • Command-local Gateway status helper keeps the original intent (ff2c044: Keep single-consumer operations with their existing consumer while preserving public and lazy-loading contracts.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +8, Tests 0. Total +8 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 10 2 +8
Tests 1 37 37 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 47 39 +8

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.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: Interrupting a pending diagnostic read can require forced CLI termination, with limited impact outside this command.
  • 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-12T16:21:55.853Z sha 2ff3080 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-12T16:51:05.729Z sha 2ff3080 :: needs maintainer review before merge. :: none

Reviewed November 12, 2026, 12:48 PM ET / 17:48 UTC (Revision 3).

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Body updated with the inspectable peer-transcript capture (base: held -> released + marker printed after SIGINT; head: held only, no late output). @clawsweeper re-review

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper 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. 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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. labels Nov 12, 2026
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Maintainer proof at f70e31a97030 (production diff unchanged from 2ff3080a; the follow-up commit only folds the new test into the existing fallback test).

Setup: node 24.22.1 in a secretless container, built CLI (pnpm build, node openclaw.mjs) on main baca36ea and on this PR. A real built Gateway runs with one Telegram account (local fake Bot API). The CLI talks to it through a local WebSocket relay that forwards every frame unchanged but holds the channels.status reply for 8 s. The signal is sent once that reply has been held for 1 s: SIGINT as a real 0x03 on a PTY, SIGTERM with kill.

Run main this PR
channels list, SIGINT during the status read not cancelled; the CLI's cleanup deadline SIGKILLs it after 2234 ms exit 130 after 134 ms
channels list, SIGTERM during the status read not cancelled; SIGKILL after 2111 ms exit 143 after 149 ms
channels list --json (SIGINT / SIGTERM runs) exits 0 before any signal: --json never reads Gateway status same, identical JSON
Uninterrupted, Gateway direct exit 0, Telegram default: installed, configured, enabled, token=*** identical
Uninterrupted, held reply (5 s timeout) exit 0, same account list identical
No Gateway running exit 0, same fallback account list identical
channels status --json exit 0 exit 0, same JSON (timings masked)

Neither build prints an account list after the signal. On main the interrupted command never finishes on its own: it waits on the status read and is killed. With this PR the read is aborted and the command exits with the normal signal code. Only the random tagline differs between outputs.

The folded cancellation test passes with this PR. With main's list.ts it fails (promise resolved "undefined" instead of rejecting).

Event log excerpts
== main list-sigint
   9779 ms  proxy holding channels.status reply for 8000ms
  10783 ms  sent Ctrl+C (0x03) to the PTY, channels.status reply held for 1 s
  13017 ms  cli exited code=-9 (signal SIGKILL)
  13017 ms  output after SIGINT: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\r\n'
== cand list-sigint
  12677 ms  cli exited code=130 (exit)
  12677 ms  SIGINT -> exit: 134 ms
== main list-sigterm
  13438 ms  cli exited code=-9 (signal SIGKILL)
  13438 ms  SIGTERM -> exit: 2111 ms
== cand list-sigterm
  11419 ms  cli exited code=143 (exit)
  11419 ms  SIGTERM -> exit: 149 ms

@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. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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 merged commit c7a4976 into openclaw:main Nov 12, 2026
113 of 116 checks passed
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Landed in c7a4976. Thanks @wangmiao0668000666.

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]>
@wangmiao0668000666
wangmiao0668000666 deleted the fix/channels-list-read-cancel branch November 13, 2026 14:21
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Thanks for merging this! Appreciate the review and the help landing it.

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