Skip to content

fix(windows): preserve staged update handoff#75649

Open
IAMSamuelRodda wants to merge 4 commits intoopenclaw:mainfrom
IAMSamuelRodda:fix/windows-ebusy-update-staged-handoff
Open

fix(windows): preserve staged update handoff#75649
IAMSamuelRodda wants to merge 4 commits intoopenclaw:mainfrom
IAMSamuelRodda:fix/windows-ebusy-update-staged-handoff

Conversation

@IAMSamuelRodda
Copy link
Copy Markdown
Contributor

Summary

Carries forward #44614 by @Eiman24, preserving their original cherry-picked commit as the first commit and adding maintainer follow-up commits on top.

This keeps the detached Windows update direction, but adjusts the implementation around the current package-update contract:

  • keeps npm global updates staged and verified before the Gateway exits
  • delegates only the Windows-locked package-tree swap and restart to the detached helper
  • keeps prepared update env handling, cmd quoting, restart supervision checks, and fallback restart behavior
  • reconciles detached helper results through the restart sentinel / update.status
  • updates docs and changelog with attribution

Validation

  • pnpm exec oxfmt --check --threads=1 src/infra/package-update-steps.ts src/infra/package-update-steps.test.ts src/infra/update-detached-result.ts src/infra/update-detached-win32.ts src/infra/update-detached-win32.test.ts src/infra/update-runner.ts src/gateway/server-methods/update.ts src/gateway/server-methods/update.test.ts src/gateway/server-restart-sentinel.ts src/gateway/server-restart-sentinel.test.ts src/infra/restart-sentinel.ts
  • pnpm test src/infra/update-detached-win32.test.ts src/infra/package-update-steps.test.ts src/gateway/server-methods/update.test.ts src/gateway/server-restart-sentinel.test.ts src/infra/update-runner.test.ts src/cli/update-cli/restart-helper.test.ts
  • pnpm tsgo
  • pnpm tsgo:core:test

Notes

I attempted to push directly to Eiman24:fix/windows-ebusy-update with --force-with-lease against c83ca14db7192665cb80af98d88722be43c5a0e1, but GitHub denied push access for this account. This draft PR is the fallback path so the fix is available without overwriting the contributor's work.

pnpm check:changed expanded to all lanes because this rebased branch has no clean ancestry with the original PR branch. The local all-lane run reached tsgo:all and then failed on an unrelated existing Matrix extension type error in extensions/matrix/src/matrix/monitor/handler.ts (dmScope / liveDmAllowFrom). The touched core typechecks and focused tests above pass.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: XL labels May 1, 2026
@IAMSamuelRodda IAMSamuelRodda marked this pull request as ready for review May 1, 2026 13:11
@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented May 1, 2026

Codex review: needs changes before merge.

Summary
The PR adds a Windows detached helper for Control UI/Gateway npm-global package swaps, restart-sentinel/update.status reconciliation, tests, docs, and a changelog entry.

Reproducibility: yes. by source inspection for the review finding. #40540 documents Windows openclaw update EBUSY steps, and the PR head still detaches only runGatewayUpdate while runPackageInstallUpdate continues through the live package-update path.

Next step before merge
A narrow automated repair can safely change the incorrect closing changelog reference without touching the Windows update implementation.

Security
Cleared: Security review cleared: the diff adds local Windows helper scripts and sentinel result handling, with no new dependencies, workflows, secret handling, or concrete command-injection issue found.

Review findings

  • [P2] Do not close the CLI update bug — CHANGELOG.md:66
Review details

Best possible solution:

Land the Control UI/Gateway detached verified-swap design after changing the #40540 changelog wording to non-closing, or broaden the implementation to cover the CLI package-update path before using closing language.

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

Yes, by source inspection for the review finding. #40540 documents Windows openclaw update EBUSY steps, and the PR head still detaches only runGatewayUpdate while runPackageInstallUpdate continues through the live package-update path.

Is this the best way to solve the issue?

Partly. The detached staged-swap approach is a maintainable fix for Control UI/Gateway update.run, but the current PR should not close #40540 unless it also covers the CLI path.

Full review comments:

  • [P2] Do not close the CLI update bug — CHANGELOG.md:66
    The changelog uses closing language for [Bug]: openclaw update command fails with EBUSY error on Windows #40540, but that report is about the openclaw update CLI path. This patch detaches only runGatewayUpdate; runPackageInstallUpdate still calls runGlobalPackageUpdateSteps without the detached swap hook, so merging this would close an issue whose reproduction is still uncovered.
    Confidence: 0.82

Overall correctness: patch is incorrect
Overall confidence: 0.82

Acceptance criteria:

What I checked:

Likely related people:

  • vincentkoc: Local blame in the shallow checkout points the current staged package update, Gateway update, and CLI update paths at Vincent Koc, and the prior ClawSweeper review also identified recent CLI update work by this handle. (role: recent update-path maintainer; confidence: medium; commits: e3d76d2e1f, cad2cef0fb8c, debb8ac76c84; files: src/infra/package-update-steps.ts, src/infra/update-runner.ts, src/cli/update-cli/update-command.ts)
  • shakkernerd: The existing review context identifies this handle with recent main commits that introduced and hardened the staged npm global update and swap behavior this PR extends. (role: staged npm update maintainer; confidence: medium; commits: 6985c6751c3d, b0127b9f1fb0, 2186080963f4; files: src/infra/package-update-steps.ts, src/infra/update-runner.ts)
  • steipete: The existing review context ties this handle to repeated work around Gateway update restart handoff and package update restart behavior near this surface. (role: adjacent Gateway restart/update maintainer; confidence: low; commits: e131eaecb502, 88da533714e5; files: src/gateway/server-methods/update.ts, src/gateway/server-restart-sentinel.ts, src/infra/restart-sentinel.ts)

Remaining risk / open question:

  • No live Windows update or local test run was performed in this read-only review; the patch still needs normal CI and Windows validation after the changelog repair.

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

@IAMSamuelRodda IAMSamuelRodda force-pushed the fix/windows-ebusy-update-staged-handoff branch from c96817b to 35313fb Compare May 2, 2026 00:19
tanmingzhen and others added 4 commits May 2, 2026 09:49
…EBUSY

On Windows, 'npm i -g openclaw@latest' fails with EBUSY when the Gateway
process is running because Node.js locks loaded .js files. The Dashboard
'Update now' button always fails on Windows for this reason.

This fix introduces a detached update flow for Windows:
1. update-runner detects Windows + global npm install scenario
2. Spawns a detached .cmd helper script (update-detached-win32.ts)
3. Returns status 'ok' with detachedResultPath so the handler knows
   to exit the Gateway process (not just SIGUSR1 in-process reload)
4. The detached helper waits for the Gateway PID to exit, runs npm
   install, then relaunches the Gateway via Scheduled Task

This mirrors the existing windows-task-restart.ts pattern but adds
the npm install step between stop and restart.

Files changed:
- src/infra/update-detached-win32.ts (new): Detached update helper
- src/infra/update-runner.ts: Windows branch in global update path
- src/gateway/server-methods/update.ts: Handle detachedResultPath
- src/infra/update-detached-win32.test.ts (new): Tests

Fixes: Dashboard 'Update now' EBUSY failure on Windows
(cherry picked from commit c83ca14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant