Skip to content

fix(update): ignore restart script spawn failures#85761

Merged
giodl73-repo merged 1 commit into
openclaw:mainfrom
giodl73-repo:fix-83892-restart-script-spawn-error
May 24, 2026
Merged

fix(update): ignore restart script spawn failures#85761
giodl73-repo merged 1 commit into
openclaw:mainfrom
giodl73-repo:fix-83892-restart-script-spawn-error

Conversation

@giodl73-repo

@giodl73-repo giodl73-repo commented May 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Make the detached gateway restart script handoff best-effort when spawn() fails immediately.
  • Attach a child error listener so ENOENT/EACCES-style spawn failures after handoff do not crash the update CLI.
  • Add focused Linux/Windows regression coverage and a changelog entry.

Fixes #83892.

Verification

2026-05-23 update after rebasing onto origin/main (acf265d4d5), head e224c84c34:

  • node scripts/run-vitest.mjs src/cli/update-cli/restart-helper.test.ts --reporter=verbose (1 file, 29 tests passed)
  • ./node_modules/.bin/oxfmt --check --threads=1 CHANGELOG.md src/cli/update-cli/restart-helper.ts src/cli/update-cli/restart-helper.test.ts
  • ./node_modules/.bin/oxlint src/cli/update-cli/restart-helper.ts src/cli/update-cli/restart-helper.test.ts
  • git diff --check origin/main...HEAD

Earlier verification before the rebase:

  • corepack pnpm install
  • corepack pnpm exec oxfmt --write --threads=1 src/cli/update-cli/restart-helper.ts src/cli/update-cli/restart-helper.test.ts CHANGELOG.md
  • OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=900000 CI=1 node scripts/run-vitest.mjs src/cli/update-cli/restart-helper.test.ts - 29 tests passed before push
  • git diff --check
  • corepack pnpm exec oxfmt --check --threads=1 src/cli/update-cli/restart-helper.ts src/cli/update-cli/restart-helper.test.ts CHANGELOG.md
  • corepack pnpm exec oxlint src/cli/update-cli/restart-helper.ts src/cli/update-cli/restart-helper.test.ts - 0 warnings, 0 errors
  • codex review --uncommitted - clean, no actionable findings before initial commit
  • Rebased on latest origin/main after PR creation to resolve the changelog conflict with fix(doctor): canonicalize git checkout detection #85735.
  • After rebase: OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=900000 CI=1 node scripts/run-vitest.mjs src/cli/update-cli/restart-helper.test.ts - 29 tests passed
  • After rebase: git diff --check fork/fix-83892-restart-script-spawn-error..HEAD
  • After rebase: corepack pnpm exec oxfmt --check --threads=1 src/cli/update-cli/restart-helper.ts src/cli/update-cli/restart-helper.test.ts CHANGELOG.md
  • After rebase: corepack pnpm exec oxlint src/cli/update-cli/restart-helper.ts src/cli/update-cli/restart-helper.test.ts - 0 warnings, 0 errors
  • After rebase: codex review --base origin/main - clean, no actionable findings

Note: node scripts/run-oxlint.mjs src/cli/update-cli/restart-helper.ts src/cli/update-cli/restart-helper.test.ts was attempted, but its preflight failed before linting touched files because the local checkout could not build unrelated WhatsApp boundary DTS artifacts: missing baileys type declarations under extensions/whatsapp/**. Direct oxlint on the touched TS files passed.

Real behavior proof

Behavior addressed: openclaw update can crash during the gateway restart handoff when the detached restart script process cannot be spawned or emits a child-process error event after spawn() returns.

Real environment tested: WSL checkout at /root/src/openclaw-85761 on Ubuntu-24.04, branch fix-83892-restart-script-spawn-error, head e224c84c34.

Exact steps or command run after this patch: node scripts/run-vitest.mjs src/cli/update-cli/restart-helper.test.ts --reporter=verbose

Evidence after fix: The focused regression test covers both the synchronous spawn() throw path and the async child-process error event path, while preserving the existing Linux, macOS, and Windows restart script behavior.

Observed result after fix: restart-helper.test.ts passed 29 tests including the new failure-mode regressions; focused static checks were clean.

What was not tested: A destructive full package self-update with an actual managed gateway restart was not run; this patch only changes the detached handoff error handling and preserves existing restart script behavior.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S maintainer Maintainer-authored PR labels May 23, 2026
@clawsweeper

clawsweeper Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Latest ClawSweeper review: 2026-05-24 00:52 UTC / May 23, 2026, 8:52 PM ET.

Workflow note: Future ClawSweeper reviews update this same comment in place.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

PR Surface
Source +5, Tests +30, Docs +1. Total +36 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 11 6 +5
Tests 1 33 3 +30
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 45 9 +36

Summary
The PR wraps the detached update restart-helper spawn handoff in best-effort error handling, adds regressions for synchronous spawn throws and async child-process error events, and adds a changelog entry.

Reproducibility: yes. for the code path: current main lacks both a try/catch around the restart script spawn and a child error listener, and the PR adds focused regressions for both failure modes. I did not run a destructive full update flow in this read-only review.

PR rating
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Summary: The patch is small and appears correct, but mock-only proof keeps it below merge-ready for an external bug-fix PR.

Rank-up moves:

  • Add redacted terminal output or logs from a real OpenClaw/Node invocation that forces the restart-script spawn failure path and shows the update command does not crash.
  • Redact private details such as IP addresses, API keys, phone numbers, non-public endpoints, and local secrets before posting proof.
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

Real behavior proof
Needs real behavior proof before merge: The PR body uses the proof template, but the after-fix evidence is a focused Vitest run rather than redacted terminal output, logs, or a recording from a real update/restart handoff; updating the PR body with real proof should trigger a fresh ClawSweeper review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • Real behavior proof is mock-only; before merge, maintainers should get redacted terminal output or logs from an actual update/restart handoff failure path, or explicitly override the proof gate.
  • The protected maintainer label means this cleanup workflow should not close or auto-merge the PR without explicit maintainer handling.

Maintainer options:

  1. Decide the mitigation before merge
    Land the small restart-helper hardening after maintainer review and real handoff proof, then let it close runRestartScript propagates synchronous spawn() errors as unhandled rejections #83892.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge
Human handling is needed because the remaining blockers are the protected maintainer label and contributor-side real behavior proof, not a narrow code repair for ClawSweeper to make.

Security
Cleared: The diff touches only the CLI restart helper, its tests, and changelog; it adds no dependency, workflow, credential, package-resolution, or new code-execution surface beyond the existing restart script spawn path.

Review details

Best possible solution:

Land the small restart-helper hardening after maintainer review and real handoff proof, then let it close #83892.

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

Yes for the code path: current main lacks both a try/catch around the restart script spawn and a child error listener, and the PR adds focused regressions for both failure modes. I did not run a destructive full update flow in this read-only review.

Is this the best way to solve the issue?

Yes, the code direction is the narrow maintainable fix: handle both synchronous spawn failures and async child-process error events at runRestartScript while preserving detached handoff behavior. The remaining blocker is proof, not an identified code defect.

Label changes:

  • add rating: 🦪 silver shellfish: Current PR rating is 🦪 silver shellfish because proof is 🦪 silver shellfish, patch quality is 🐚 platinum hermit, and The patch is small and appears correct, but mock-only proof keeps it below merge-ready for an external bug-fix PR.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body uses the proof template, but the after-fix evidence is a focused Vitest run rather than redacted terminal output, logs, or a recording from a real update/restart handoff; updating the PR body with real proof should trigger a fresh ClawSweeper review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • remove rating: 🌊 off-meta tidepool: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P2: This is a normal-priority CLI update crash/availability fix with a narrow restart-helper surface and limited blast radius.
  • rating: 🦪 silver shellfish: Current PR rating is 🦪 silver shellfish because proof is 🦪 silver shellfish, patch quality is 🐚 platinum hermit, and The patch is small and appears correct, but mock-only proof keeps it below merge-ready for an external bug-fix PR.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body uses the proof template, but the after-fix evidence is a focused Vitest run rather than redacted terminal output, logs, or a recording from a real update/restart handoff; updating the PR body with real proof should trigger a fresh ClawSweeper review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

What I checked:

  • current main source: Current main's runRestartScript spawns /bin/sh or cmd.exe detached and immediately calls unref() with no try/catch and no ChildProcess error listener. (src/cli/update-cli/restart-helper.ts:409, acf265d4d51d)
  • PR implementation: PR head wraps the spawn handoff in a try/catch and attaches child.on("error", () => {}) before unref(), preserving the existing detached spawn options. (src/cli/update-cli/restart-helper.ts:409, e224c84c348c)
  • PR regression coverage: PR head adds focused tests for a synchronous spawn throw and for invoking the async child-process error handler without throwing, while updating Linux and Windows spawn assertions to require the listener. (src/cli/update-cli/restart-helper.test.ts:642, e224c84c348c)
  • dependency contract proof: Node v24.15 documentation says the error event is emitted when a process could not be spawned, and Node v24.15 source shows spawn() constructs a ChildProcess, calls child.spawn(options), then returns the child.
  • proof gate: The PR body's Real behavior proof section reports only node scripts/run-vitest.mjs src/cli/update-cli/restart-helper.test.ts --reporter=verbose; that is useful regression coverage but not a real update/restart handoff run. (e224c84c348c)
  • protected review state: The provided live GitHub context lists the protected maintainer label, so conservative cleanup should keep this PR open for explicit maintainer handling.

Likely related people:

  • steipete: Current main blame for runRestartScript and the update-command caller points to a recent carry-forward commit, and shortlog/history show the most touches in the update CLI/restart helper area. (role: recent area contributor; confidence: high; commits: a705a9c911bc, 438799e929d4, 089e038dfeb9; files: src/cli/update-cli/restart-helper.ts, src/cli/update-cli/restart-helper.test.ts, src/cli/update-cli/update-command.ts)
  • artale: git log -S runRestartScript traces the standalone restart-script helper and its initial test/update-command integration to the February update restart implementation. (role: introduced behavior; confidence: high; commits: b1d5c71609c3; files: src/cli/update-cli/restart-helper.ts, src/cli/update-cli/restart-helper.test.ts, src/cli/update-cli/update-command.ts)
  • vincentkoc: Recent update CLI history includes self-update restart flow work in update-command.ts, which is adjacent to the restart handoff path this PR changes. (role: adjacent update-flow contributor; confidence: medium; commits: a24af4910018; files: src/cli/update-cli/update-command.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against acf265d4d51d.

@giodl73-repo
giodl73-repo force-pushed the fix-83892-restart-script-spawn-error branch from 779bc4e to 989ad91 Compare May 23, 2026 15:48
@clawsweeper clawsweeper Bot added 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. labels May 23, 2026
@clawsweeper

clawsweeper Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@clawsweeper clawsweeper Bot added the P2 Normal backlog priority with limited blast radius. label May 23, 2026
@giodl73-repo

Copy link
Copy Markdown
Contributor Author

CI triage for checks-node-core-runtime-infra-process:

  • Failed job rerun: https://github.com/openclaw/openclaw/actions/runs/26337000097/job/77533463581
  • Failure is src/config/config.pruning-defaults.test.ts > adds cacheRetention defaults for dated Anthropic primary model refs expecting cfg.agents.defaults.models["anthropic/claude-sonnet-4-20250514"].params.cacheRetention to be "short", but receiving undefined.
  • This PR branch itself passes that test locally: OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=900000 CI=1 node scripts/run-vitest.mjs src/config/config.pruning-defaults.test.ts passed 8/8 in /root/src/openclaw-83892.
  • A clean latest origin/main worktree at a04566da11 reproduces the same failure with the same command. That means the PR check failure is coming from current base/main state, not from the restart-helper patch.
  • Likely source is b6530beb05 fix: prune retired model catalog entries: applying Anthropic defaults for anthropic/claude-sonnet-4-20250514 now writes cacheRetention under canonical anthropic/claude-sonnet-4-6, while the existing test still checks the retired dated key.

Maintainer alert: I did not fold a config-defaults/test change into this PR because that is a config/model-default boundary and unrelated to #83892. This PR remains scoped to update restart handoff error handling.

@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed 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. labels May 23, 2026
@giodl73-repo
giodl73-repo force-pushed the fix-83892-restart-script-spawn-error branch from 654fde1 to e224c84 Compare May 24, 2026 00:47
@clawsweeper clawsweeper Bot added 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 rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels May 24, 2026
@giodl73-repo
giodl73-repo merged commit 566d8cd into openclaw:main May 24, 2026
115 of 119 checks passed
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 24, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runRestartScript propagates synchronous spawn() errors as unhandled rejections

2 participants