fix: restart gateway after isolated cron setup timeout#89055
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed June 14, 2026, 6:25 AM ET / 10:25 UTC. Summary PR surface: Source +876, Tests +1377. Total +2253 across 28 files. Reproducibility: yes. for the source-level path: current main has the isolated cron setup-timeout watchdog/error path and no restart hook. I did not run a live repro in this read-only review, and the live proof in the PR body is stale relative to current head. Review metrics: 2 noteworthy metrics.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Merge only after maintainers accept automatic safe restart for this failure class and current-head real or built-runtime proof demonstrates setup-timeout restart plus cron lifecycle drain/reset recovery. Do we have a high-confidence way to reproduce the issue? Yes for the source-level path: current main has the isolated cron setup-timeout watchdog/error path and no restart hook. I did not run a live repro in this read-only review, and the live proof in the PR body is stale relative to current head. Is this the best way to solve the issue? Mostly yes on code shape: the PR uses a cron-owned callback and the existing safe restart coordinator instead of inventing a parallel restart path. The remaining question is policy and proof, not a clearly better implementation layer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 37e3e895b020. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +876, Tests +1377. Total +2253 across 28 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
b370977 to
853a75b
Compare
|
@clawsweeper re-review\n\nAdded PR-head proof to the Real behavior proof section: verbose gateway/cron/infra test output now shows the setup-timeout callback requests safe restart, and the existing restart layer coalesces/defers repeated restart requests. |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper re-review I updated the PR body with stronger PR-build proof in the Real behavior proof section. New evidence added:
Please re-evaluate proof quality/rank with this added built-runtime evidence. The remaining policy question is maintainer acceptance of the automatic safe Gateway restart tradeoff. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
354de1a to
7231c3f
Compare
7231c3f to
13d06b5
Compare
|
Maintainer fixes pushed to this PR branch. Final head SHA: 13d06b5 Verification:
|
Summary
Root Cause
Cron jobs that use isolated agent turns can fail before the runner starts with
cron: isolated agent setup timed out before runner start. Today that error is recorded and alerted, but it is not treated as a platform-level gateway/isolated-runner health failure. Individual cron workflows can self-repair around it, but the shared failure mode keeps recurring across unrelated jobs.Impact
When this failure class occurs, OpenClaw now asks the existing safe-restart coordinator to restart only after the normal preflight drain says it is safe. This should reduce repeated user-visible cron failure cards without interrupting active work.
Real behavior proof
cron: isolated agent setup timed out before runner startcards instead of recovering centrally.2026.5.28, with active background workload.354de1a3b99027027b303c29b8852ec8fef9091d; ran the PR-head proof commandpnpm test src/gateway/server-cron.test.ts src/cron/service/timer.regression.test.ts src/infra/restart-coordinator.test.ts src/infra/infra-runtime.test.ts --reporter verbose; ran the production build commandnode scripts/build-all.mjs; then ran the built-runtime proof commandnode --import tsx /tmp/openclaw-pr-89055-setup-timeout-proof.mjs. I also checked the real recovered machine withopenclaw gateway status,openclaw status --json, andps -p 93467 -o pid,pcpu,pmem,rss,etime,command.node scripts/build-all.mjspassed on PR head354de1a3b99027027b303c29b8852ec8fef9091d. The built-runtime proof then ran a controlled setup stall through the real cron timeout path and the real safe restart scheduler. Its output showedproductionBuildCompleted=true,distContainsGatewayHook=true,elapsedMs=60282,result.error="cron: isolated agent setup timed out before runner start",restartRequests[0].status="scheduled",restartRequests[0].preflightSafe=true,restartRequests[0].restartCoalesced=false,restartRequests[0].restartMode="emit",restartRequests[0].restartReason="cron.isolated_agent_setup_timeout",sigusr1Events[0].authorized=true,sigusr1Events[0].recovered=true, and all four assertions true: setup timeout result, safe restart scheduled, gateway run loop recovered, and production dist contains the gateway hook.openclaw gateway statuswithRuntime: running (pid 93467, state active),Connectivity probe: ok,Capability: admin-capable, andGateway version: 2026.5.28. Copied liveopenclaw status --jsonoutput showedgateway.reachable=true,gateway.connectLatencyMs=45,queuedSystemEvents=[], andtasks.byStatus.queued=0. Copied livepsoutput showed gateway pid93467around1.0%CPU,3.2%memory, RSS534560KB. Before recovery, the same setup had a stale gateway timeout and a gateway node process around109%CPU with roughly2.8GBRSS. Supplemental PR-head terminal output also showed✓ |gateway| ... requests a safe gateway restart when isolated cron setup times out,✓ |infra| ... coalesces duplicate scheduled restarts into a single pending timer, and✓ |infra| ... defers SIGUSR1 until deferral check returns 0.22/22, infra34/34, and cron43/43, proving this patch requests the same safe restart path for the setup-timeout class while the existing coordinator coalesces/defers repeated restart requests.Testing
pnpm test src/gateway/server-cron.test.ts src/cron/service/timer.regression.test.ts src/infra/restart-coordinator.test.ts src/infra/infra-runtime.test.ts --reporter verbosepnpm test src/cron/service/timer.regression.test.ts src/gateway/server-cron.test.tspnpm tsgo:coregit diff --checkNote:
pnpm check:changedwas also attempted locally before this PR, but the local Blacksmith Testbox wrapper failed its own--version/--helpsanity check before project checks could run.