Skip to content

fix(cli): stop pending cron inventory reads on interrupt - #187726

Merged
obviyus merged 2 commits into
openclaw:mainfrom
SunnyShu0925:fix/BUG-265-cron-list-interrupt
Oct 29, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
SunnyShu0925:fix/BUG-265-cron-list-interrupt

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: cron list and cron show could keep waiting after Ctrl-C or SIGTERM, then print a late Gateway timeout/failure document for the cancelled read. The root signal owner already preserved the interrupt exit code, but the inventory and lookup RPCs did not share its cancellation signal.

Why This Change Was Made

The existing inventory/lookup owner now passes the invocation signal to read RPCs and checks it between pages. The existing cron error owner leaves an invocation-cancelled AbortError to root cleanup while still reporting ordinary failures. There is no separate forwarding error handler, new signal option or caller-specific cancellation policy.

Mutating RPCs are unchanged and receive no cancellation signal. An accepted mutation still waits for its receipt; a rejection after interruption remains visible. Completed exit outcomes keep their existing identity. Pagination, snapshot consistency, legacy Gateway compatibility and scheduler execution policy are unchanged.

Preserves @SunnyShu0925's original contributor commit and implementation intent. AI-assisted repair, simplification and validation.

User Impact

Interrupting pending list/show reads promptly returns the shell with status 130 for SIGINT or 143 for SIGTERM, without a late table or failure document. Root interrupt notices remain on stderr. Interrupting an already-sent add or edit does not undo the mutation or hide its eventual failure.

Evidence

Captured shipped-CLI main/candidate proof and controls on exact head bc1043097874f946aff1c7cd953897d2b86b30ab:

  • Current main and candidate built in secretless node:24.22.1 Docker using the repository's supported runtime build. Real CLI registration, signal cleanup, Gateway client and WebSocket transport; a loopback peer completes authentication and withholds accepted replies. No production module interception or real credentials/state.
  • list and show, SIGINT and SIGTERM, twice per signal per artifact: main takes 8.01–8.18s and prints a late cli_error; candidate takes 24–47ms, exits 130/143, and keeps stdout empty.
  • Normal list/show controls each run twice per artifact: exit 0 and byte-identical stdout hashes.
  • Accepted and rejected cron add controls run twice per signal per artifact. Connections stay open until the delayed receipt; accepted results and real rejection diagnostics remain visible before exit 130/143. 40 completed built-CLI cases total.
  • Focused cron command, shared error and pagination suites: 140 passed. Final cancellation table on main: 2 failed / 3 existing run-wait controls passed. Focused TypeScript, repository type-aware lint, changed source and docs formatting passed. Hosted broad CI is assessed separately.

Simplification reuses the existing cancellation table and removes the duplicate new process suite, its fixture/registry scaffolding, unused signal-option surface and parallel error handler. Existing run-wait phases remain covered. Whole PR: production +16 lines, tests −2 lines, docs +5 lines; no increased ratchet or allocation exemption.

The synthetic peer controls pending-RPC and receipt timing. This proves the shipped CLI's cancellation, output and accepted-write custody, not scheduler execution or persistent automation storage durability.

Merge danger

Two-way door: reverting restores the prior cancellation behavior; no config or state migration is introduced. Blast radius is Gateway-backed cron inventory/lookup reads and their existing error renderer during invocation cancellation. Accepted mutations, ordinary errors, pagination semantics and scheduler state are unchanged.

@clawsweeper

clawsweeper Bot commented Oct 29, 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 cli CLI command changes size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Oct 29, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Connect cron inventory and job lookup reads to invocation cancellation while preserving ordinary errors and accepted mutation outcomes.

Example: Press Ctrl-C while openclaw cron list --json --timeout 8000 awaits a Gateway reply.

  • Before: The command waits about eight seconds and prints a late cli_error document.
  • After: The pending read stops promptly, stdout stays empty, and root cleanup exits with status 130.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-level repair with shipped-entry-point fault proof, useful regression coverage, preserved mutation controls, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Exact-head shipped-CLI evidence from #187726 (comment) exercises real command registration, root cleanup, Gateway client, and WebSocket transport in secretless Node 24.22.1 Docker: pending list/show reads stop on SIGINT/SIGTERM with empty stdout and exit 130/143, normal output remains identical, and delayed accepted/rejected add receipts remain visible.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: After an interrupt, cron list/show can keep waiting and later print a failure document for a read the user already cancelled.
Reason: Prompt cancellation restores the established CLI lifecycle contract without adding options or changing scheduler behavior.

Merge readiness

✅ Ready for maintainer review

Keep this PR: it fixes a demonstrated cancellation bug still present on current main, preserves mutation receipts, and has no actionable findings; exact-head CI remains pending.

Priority: P2
Reviewed head: bc1043097874f946aff1c7cd953897d2b86b30ab

Before merge

None.

Findings

None.

Agent review details

How this fits together

Cron CLI commands use a shared inventory and lookup owner to issue Gateway RPCs and render results; the existing invocation work scope supplies cancellation and root cleanup owns interrupt exit status.

flowchart LR
  A[Cron CLI command] --> B[Inventory and lookup owner]
  C[Invocation work scope] --> B
  B --> D[Gateway RPC client]
  D --> E[WebSocket Gateway]
  B --> F[Cron output and error owner]
  C --> G[Root cleanup and exit status]
Loading

Technical review

Best possible solution:

Land the focused cancellation wiring through the existing read and error owners once ordinary exact-head gates pass.

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

Published built-CLI baseline/candidate evidence demonstrates the failure and recovery with both signals, and fetched main retains the same unsignalled read paths; this read-only review executed no target code.

Is this the best way to solve the issue?

The patch is the smallest complete repair: pending reads consume the existing invocation signal, pagination checks cancellation, and the shared error owner suppresses cancellation without hiding ordinary mutation failures.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 54df949 adds src/cli/cron-cli/list-jobs.ts:35 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 54df949aaa08; files: src/cli/cron-cli/list-jobs.ts)
  • Alix-007: Raw commit 6580ecf adds src/cli/cron-cli.test.ts:307 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6580ecf82903; files: src/cli/cron-cli.test.ts)

PR surface

Source +16, Tests -2, Docs +5. Total +19 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 23 7 +16
Tests 1 14 16 -2
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 42 23 +19

Review metrics

Metric Value Why it matters
Production versus regression code Production +23/-7 (net +16); tests +14/-16 (net -2) The necessary growth threads cancellation through existing owners while extending the existing regression table without new scaffolding.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Interrupting an operator's cron inventory command can leave it waiting until its RPC timeout and emit a misleading late failure.
  • 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 (4 earlier review cycles)
  • reviewed 2026-10-29T14:50:27.720Z sha c969368d7978f0c8bb2228c983aa197677b4bb9f :: needs changes before merge. :: [P2] Preserve errors from uncancelled mutation requests | [P2] Handle cancellation in the cron show consumer
  • reviewed 2026-10-29T15:57:06.420Z sha 4d0cac0 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-29T16:33:04.566Z sha 4d0cac0 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-29T16:43:03.657Z sha 4d0cac0 :: needs maintainer review before merge. :: none

Reviewed October 29, 2026, 1:40 PM ET / 17:40 UTC (Revision 5).

`openclaw cron list` read `cron.list` pages without the command's interrupt
signal: after Ctrl-C the accepted request stayed pending until its RPC timeout,
then a late "outcome unknown" error printed and the command exited 1 instead of
130. The pager also kept requesting further pages and snapshot restarts, so the
uninterruptible window grew with inventory size.

Thread the CLI work signal through the inventory pager and the exact-ID/name
lookup, check it between pages, and let an interrupted cron read stay with the
root signal owner instead of rendering a command failure. Read-only reads stop
quietly; mutations keep their existing lifetime, so a rejection that settles
after Ctrl-C still reports itself.

`cron show` reads through the same lookup and now uses that handler too. The
process test covers an inventory read, a cancelled lookup, and a rejected
mutation, and is registered in the isolated CLI process lane.
@SunnyShu0925
SunnyShu0925 force-pushed the fix/BUG-265-cron-list-interrupt branch from c969368 to 4d0cac0 Compare October 29, 2026 15:49
@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Oct 29, 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. 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 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. labels Oct 29, 2026
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review.

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. labels Oct 29, 2026
@clawsweeper clawsweeper Bot removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 29, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S and removed size: M labels Oct 29, 2026
@obviyus

obviyus commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Built cron CLI interruption proof

Candidate bc1043097874f946aff1c7cd953897d2b86b30ab; current-main baseline bbde2b822c133f615d83a9f1db109960c4d68f9e. Both were built from source using the repository's supported pnpm build:runtime route in a secretless node:24.22.1 Docker container. A first full main build hit a bundler hook timeout before producing a usable artifact; the supported runtime builds completed without source patches or clock changes. Setup failures are not counted as reproduction.

Shipped entry point and fault boundary

Each case launches the built openclaw.mjs --profile <isolated-profile> cron ... --json command with its own HOME, config, state directory and workspace. The exact binary prints its resolved config and SQLite path before the command; the harness refuses paths outside that case's isolated root.

The CLI uses its real command registration, invocation signal owner, Gateway client and WebSocket transport. A loopback Gateway-compatible peer completes the real protocol handshake, records the requested method, then deliberately withholds the accepted read's response. SIGINT or SIGTERM is sent only after that request is observed on the wire. No production module is mocked or preloaded and no real Gateway, credentials or user state is used.

For each signal, cron list and cron show job-1 were run twice on main and twice on the built candidate:

                                main                             candidate
cron list + SIGINT x2            ~8.03–8.07s; exit 130; cli_error  24–47ms; exit 130; stdout empty
cron list + SIGTERM x2           ~8.03–8.07s; exit 143; cli_error  24–47ms; exit 143; stdout empty
cron show + SIGINT x2            ~8.01–8.18s; exit 130; cli_error  26–36ms; exit 130; stdout empty
cron show + SIGTERM x2           ~8.01–8.18s; exit 143; cli_error  26–36ms; exit 143; stdout empty

The ranges combine both signal groups for each command. Main waits out the configured 8000ms RPC timeout and emits a late cli_error document warning that the accepted request's outcome is unknown. The candidate closes the pending read and returns promptly without a late result or failure document. Root signal notices on stderr are preserved; this does not claim entirely empty stderr.

Normal completion and accepted-mutation controls

  • Normal list and show: twice on each artifact, exit 0, one successful response, and byte-identical stdout hashes across main/candidate repeats.
  • Accepted cron add: twice per signal per artifact. The peer withholds settlement until 700ms after request acceptance. The connection remains open until that receipt, the accepted job result is printed, and root cleanup exits 130/143. Observed post-signal completion: 740–862ms on candidate, 743–857ms on main.
  • Rejected cron add: twice per signal per artifact, with the same delayed receipt. The real INVALID_REQUEST response with automation store is read-only remains visible in the canonical cli_error document after interruption; the connection stays open until settlement and exit remains 130/143. Candidate completion: 739–886ms; main 738–746ms.

That is 40 completed built-CLI cases across the two artifacts, in addition to the initial main reproduction. The peer is synthetic specifically to control accepted-but-pending RPC timing; this proves CLI cancellation, output and write-receipt custody, not scheduler execution or automation storage durability.

Focused checks and simplification

  • node scripts/run-vitest.mjs src/cli/cron-cli.test.ts src/cli/cron-cli/shared.test.ts src/cli/cron-cli/cron-pagination.gateway.test.ts: 140 passed.
  • Final cancellation regression table against unchanged main production: 2 failed / 3 passed. New inventory/show cases fail because the accepted read does not settle when the invocation scope closes; all existing cron-run sleep/request/completion cases still pass.
  • Repository type-aware Oxlint on the two production owners and regression file: passed. Focused TypeScript graph for these cron tests: passed. Changed source and docs formatting: passed.
  • Kept the contributor's commit. Folded the cancellation-only guard into the existing cron error owner instead of retaining a parallel forwarding helper and five caller edits. Removed the unused new signal-option surface; the existing invocation scope supplies cancellation. Mutating RPCs remain unsignalled and completed exit outcomes keep their identity.
  • Expanded the existing cancellation table, retaining its original three phases. Removed the duplicate new process suite and its fixture/registry scaffolding; the broader built-process evidence above remains inspectable here. The mock now exposes the existing spy directly instead of padding an artificial fourth argument and laundering it as a number.
  • Whole PR against its merge base: production +16 lines, tests −2 lines, docs +5 lines. No ratchet, allocation exemption or baseline was increased.

Exact-head final disposition

For bc1043097874f946aff1c7cd953897d2b86b30ab:

  • ClawSweeper review: 5/6 overall, proof and patch quality; no findings or before-merge items.
  • CI run 40922797978: success, 0 failing jobs / 0 cancelled CI jobs.
  • Exact-head ci-gate: success.
  • Two separate auto-response automation jobs were cancelled before running any steps (first, second); these are not product-check failures. No CI job was rerun and no green-seeking push was made.
  • GitHub reports the PR OPEN, current head unchanged, merge state CLEAN. The worker has not merged it.

@obviyus

obviyus commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 29, 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 29, 2026
@obviyus
obviyus merged commit 8b8c33e into openclaw:main Oct 29, 2026
126 of 130 checks passed
@obviyus

obviyus commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Landed in 8b8c33e. Thanks @SunnyShu0925. cron list and show now stop promptly on Ctrl-C or a service stop.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 30, 2026
…7726)

fix(cli): stop cron list and show on Ctrl-C and SIGTERM

openclaw cron list and cron show ignored SIGINT and SIGTERM while waiting for the Gateway, so they kept waiting about 8 s and then printed a late failure. Pending list and show reads now cancel on the first signal, print nothing late and exit with 130 or 143. An add or edit already sent to the Gateway still waits for its receipt and reports any failure; an interrupt doesn't undo it. The cron CLI docs describe this.

Evidence: built CLI on Node 24.22.1 (40 cases). Interrupting list and show with SIGINT or SIGTERM, main waited 8.0 to 8.2 s and printed late failures (twice each); with this change the CLI exited 130 or 143 in 24 to 47 ms with empty stdout (twice each). Normal output is byte-identical, and accepted and rejected mutation receipts are still shown. Details: openclaw#187726 (comment).

Thanks @SunnyShu0925.

Co-authored-by: SunnyShu <0668000539@local>
Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 11, 2026
fix(cron): stop pending cron reads promptly on Ctrl+C

Pressing Ctrl+C or sending SIGTERM during openclaw cron status, get, runs or a scratch read did not reach the Gateway request, so the CLI kept the socket open until its cleanup force-killed it about 2 seconds later. These reads now go through one helper that passes the command's existing abort signal to the Gateway call, and the existing cron error handler already drops the resulting abort, so nothing prints afterwards. The scratch read before a set or unset is cancellable too, so Ctrl+C there stops before the write is sent. Mutations still wait for their receipt. This completes the cron read commands after #187726. No new text.

Evidence: the built CLI in a real PTY with --json against a real built Gateway behind a WebSocket proxy holding the read replies, two runs each plus the exact head. On main every interrupted read kept the request open and was SIGKILLed about 2.1 s after Ctrl+C or SIGTERM; with this change the CLI exits 130 within 0.03-0.16 s with empty stdout, and SIGTERM exits 143. Uninterrupted reads return the same JSON on both, and an interrupted cron add whose receipt arrives still prints its confirmation on both. Net 0 test lines. Details: #197315 (comment) and #197315 (comment).

Thanks @Alix-007.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 12, 2026
fix(cron): stop pending cron reads promptly on Ctrl+C

Pressing Ctrl+C or sending SIGTERM during openclaw cron status, get, runs or a scratch read did not reach the Gateway request, so the CLI kept the socket open until its cleanup force-killed it about 2 seconds later. These reads now go through one helper that passes the command's existing abort signal to the Gateway call, and the existing cron error handler already drops the resulting abort, so nothing prints afterwards. The scratch read before a set or unset is cancellable too, so Ctrl+C there stops before the write is sent. Mutations still wait for their receipt. This completes the cron read commands after openclaw#187726. No new text.

Evidence: the built CLI in a real PTY with --json against a real built Gateway behind a WebSocket proxy holding the read replies, two runs each plus the exact head. On main every interrupted read kept the request open and was SIGKILLed about 2.1 s after Ctrl+C or SIGTERM; with this change the CLI exits 130 within 0.03-0.16 s with empty stdout, and SIGTERM exits 143. Uninterrupted reads return the same JSON on both, and an interrupted cron add whose receipt arrives still prints its confirmation on both. Net 0 test lines. Details: openclaw#197315 (comment) and openclaw#197315 (comment).

Thanks @Alix-007.

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

cli CLI command changes docs Improvements or additions to documentation 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