Repository navigation
fix(cron): Gateway exits on resume when a queued cron run hits a storage error - #175678
Conversation
resumeScheduling() started the cron run-queue drain without observing it, so a non-transient storage failure while resuming after a suspension reached the fatal unhandled-rejection handler and stopped the Gateway. Log it the way the same-store wake path does; the queued run stays durable for a later drain. Co-authored-by: wangmiao0668000666 <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR catches background cron queue-drain failures after scheduling resumes and documents the warning. Example: A queued command job encounters ERR_SQLITE_ERROR during Gateway resume.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review This PR fixes a real Gateway crash path still present on current main; the narrow patch has no actionable findings, and CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe cron lifecycle resumes scheduling and starts queue activation; the durable worker owns requests and activation, while awaited manual callers receive errors. flowchart TD
A[Gateway resume RPC] --> B[Suspend coordinator]
B --> C[Cron lifecycle]
C --> D[Queue drain]
D --> E[SQLite worker activation]
E --> F[Job launcher]
D --> G[Background warning observer]
Technical reviewBest possible solution: Retain the direct background rejection observer while preserving worker-owned queue state and error propagation to awaited callers. Do we have a high-confidence way to reproduce the issue? Source confirms the unobserved promise on current main, and the supplied built-Gateway comparison demonstrates the fatal storage-error path; this read-only review ran no target code. Is this the best way to solve the issue? The patch repairs the detached caller's missing observer using the existing wake-path contract without swallowing errors in shared queue operations. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 80e0c1f6ff4c. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +2, Docs +1. Total +3 across 2 files. Added test files: 0. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed October 31, 2026, 7:55 AM ET / 11:55 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Independent built Gateway / shipped CLI proofCandidate Both arms were independently installed and built with the canonical full runtime build in secretless Linux Node 24.22.1 containers. Each run used fresh task-owned home/state/config paths, a distinct loopback port, and a real command cron job ( The external harness installed a job-specific SQLite Candidate captures also read the persisted job state: Baseline logs after the successful resume RPC: *The baseline's fatal shutdown subsequently marks the pending manual request skipped with 18 existing tests passed across Credit: @yxshee; predecessor #172273 by @wangmiao0668000666 identified the same missing observer. No system clock was changed. All application logs and shutdown traces are retained; the harness kills any remaining CLI process group after its shutdown grace. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Exact-head CI classification — paused on unrelated redHead Current
Independent local receipt: I fetched the actual hosted merge tree The outputs are identical. This PR adds a catch to the cron resume caller and one documentation bullet; it does not modify the visitor-access test helper, its promises, or its types. An earlier direct-head-only lint probe passed because hosted CI tests the newer merge tree; that passing probe is not used as failure-independence evidence. Cancelled count: 2, both auto-response jobs (124529653503 and 124529660083); no diff-covering test jobs were cancelled. No hosted rerun or further push was made. Retaining the worktree, container/build volume, harness, exact merge-tree comparison and logs for maintainer resumption; not claiming landing-ready while CI is red. |
|
Maintainer override: the only red, |
…age error (openclaw#175678) fix(cron): don't crash the Gateway when a detached resume drain is rejected After a cron resume, the drain of queued jobs ran detached. If it rejected, for example on a storage error, nothing observed the rejection, and the Gateway exited with a fatal unhandled rejection. The detached drain now goes through the existing wake-path catch and log, so the Gateway stays up and the queued job state is kept. Errors that callers await directly, such as manual storage errors, are still surfaced. Evidence: built Gateway with real command cron jobs and the shipped suspend and resume RPCs. On main, a rejected resume drain caused a fatal unhandled rejection and the Gateway exited (twice). With this change it logged the existing warning, stayed healthy and kept the queued receipt and job state (twice). Normal resume and execution worked on both refs. Details: openclaw#175678 (comment). Thanks @yxshee. Co-authored-by: wangmiao0668000666 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Backport #175678 from 159d00b. Retain queued receipts and direct caller failures; observe only the detached resume drain. Add a real storage-fault regression covering retry. Co-authored-by: wangmiao0668000666 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Related #172273. The Gateway can exit with
Unhandled promise rejectionwhen scheduling resumes while a cron run is queued and queue activation fails with a non-transient storage error. The detached resume drain previously dropped its rejecting promise; the synchronous suspend coordinator cannot catch it.User Impact
The Gateway now observes that background rejection and logs
cron: queue drain delayed, matching the existing same-store wake path. The request stays queued while the Gateway remains available. Awaited callers such as a manualcron.runstill receive the storage error. No new retry, persistence format, scheduling policy, or configuration option.Why This Change Was Made
Attach the existing catch/log contract at the detached caller, without changing
drainCronRunQueueor its awaited callers. All contributor commits are preserved. Credit @yxshee and #172273 by @wangmiao0668000666, which identified the same missing observer.The follow-up documents the warning and removes the added regression/imports to satisfy the explicit zero-net-new-test ceiling. Existing tests and assertions remain unchanged. Simplification keeps the direct observer rather than adding an abstraction. Final merge-base diff: production +3/-1, docs +1/-0, tests +0/-0.
Evidence
Independent built Gateway / shipped CLI before-and-after proof: two main runs exit 1 with the fatal unhandled-rejection log and failed health; two candidate runs log the warning, remain healthy, and retain the unchanged queued receipt plus persisted queued job state. Normal suspend/resume and command execution pass, and manual storage errors are surfaced in both arms.
The proof uses isolated Linux Node 24.22.1 full runtime builds, real command cron jobs and shipped suspend/resume/health RPCs. An external, job-specific SQLite activation trigger produces a real non-transient storage rejection. This is controlled fault injection, not organic corruption or a full-disk claim. No synthetic in-process latch replaces the Gateway proof.
18 existing tests passed across queue and lifecycle suites; targeted formatting passed. Evidence describes initial harness observation mistakes and retains their traces. Remaining CLI process groups are stopped after the shutdown grace.
Merge Danger
Two-way door: a revert restores the previous detached rejection behavior; there is no schema or config migration. Blast radius is background cron queue draining when Gateway scheduling resumes. The change affects error observation only; queued state and errors awaited by callers retain their owners.