openclaw - 💡(How to fix) Fix [Bug] gateway can't recover from npm chunk-hash replacement during in-place upgrade — graceful shutdown depends on now-missing chunk [3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#77087Fetched 2026-05-05 05:52:27
View on GitHub
Comments
3
Participants
3
Timeline
8
Reactions
2
Timeline (top)
commented ×3mentioned ×2subscribed ×2closed ×1

When npm install -g openclaw@<newver> runs while the openclaw gateway is alive, the new install replaces hash-suffixed chunk files in dist/ (e.g. legacy-config-issues-CClZWCli.jslegacy-config-issues-BxN-Pz1M.js). The running gateway process retains references to the old chunk hashes and on next config reload fails with ERR_MODULE_NOT_FOUND. Worse, the graceful shutdown path itself depends on a now-missing chunk (server-close-DsVPJDIx.js), so openclaw gateway restart --force cannot complete shutdown — only launchctl kickstart -k (or equivalent SIGKILL + respawn) recovers.

Error Message

2026-05-04T11:08:17.896+08:00 [reload] config reload skipped (invalid config): : read failed: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/homebrew/lib/node_modules/openclaw/dist/legacy-config-issues-CClZWCli.js' imported from /opt/homebrew/lib/node_modules/openclaw/dist/io-BcjzQKwO.js ... (repeats every ~600ms in a flap loop) 2026-05-04T11:17:18.124+08:00 [reload] config change requires gateway restart (plugins.installs.brave) 2026-05-04T11:17:18.335+08:00 [gateway] SIGUSR1 restart ignored (not authorized; commands.restart=false or use gateway tool). 2026-05-04T11:17:18.522+08:00 [gateway] shutdown error: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/homebrew/lib/node_modules/openclaw/dist/server-close-DsVPJDIx.js' imported from /opt/homebrew/lib/node_modules/openclaw/dist/server.impl-B11albXx.js

Root Cause

When npm install -g openclaw@<newver> runs while the openclaw gateway is alive, the new install replaces hash-suffixed chunk files in dist/ (e.g. legacy-config-issues-CClZWCli.jslegacy-config-issues-BxN-Pz1M.js). The running gateway process retains references to the old chunk hashes and on next config reload fails with ERR_MODULE_NOT_FOUND. Worse, the graceful shutdown path itself depends on a now-missing chunk (server-close-DsVPJDIx.js), so openclaw gateway restart --force cannot complete shutdown — only launchctl kickstart -k (or equivalent SIGKILL + respawn) recovers.

Fix Action

Fix / Workaround

Additional information

  • Last known good behavior: in 2026.5.1 era, npm install -g openclaw@<newver> followed by openclaw gateway restart --force was a normal upgrade flow without this bricked state. (The vite/rollup chunk-hash strategy may have been introduced or made more aggressive recently — not 100% confirmed from outside.)
  • Suggested mitigation paths:
    • Eager-import the shutdown path (or inline it) so gateway shutdown never touches the file system after startup.
    • Document launchctl kickstart -k (or platform equivalent) as the recommended in-place upgrade path, not gateway restart --force.
    • Have gateway restart --force detect missing-chunk errors and fall through to SIGKILL of the running PID itself.

Code Example

2026-05-04T11:08:17.896+08:00 [reload] config reload skipped (invalid config): : read failed: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/homebrew/lib/node_modules/openclaw/dist/legacy-config-issues-CClZWCli.js' imported from /opt/homebrew/lib/node_modules/openclaw/dist/io-BcjzQKwO.js
... (repeats every ~600ms in a flap loop)
2026-05-04T11:17:18.124+08:00 [reload] config change requires gateway restart (plugins.installs.brave)
2026-05-04T11:17:18.335+08:00 [gateway] SIGUSR1 restart ignored (not authorized; commands.restart=false or use gateway tool).
2026-05-04T11:17:18.522+08:00 [gateway] shutdown error: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/homebrew/lib/node_modules/openclaw/dist/server-close-DsVPJDIx.js' imported from /opt/homebrew/lib/node_modules/openclaw/dist/server.impl-B11albXx.js

---

$ ls /opt/homebrew/lib/node_modules/openclaw/dist/legacy-config-issues*.js
/opt/homebrew/lib/node_modules/openclaw/dist/legacy-config-issues-BxN-Pz1M.js
/opt/homebrew/lib/node_modules/openclaw/dist/legacy-config-issues-GeD6gJjS.js
# CClZWCli (the one the running process imported) is gone — was the previous version's hash

---

launchctl kickstart -k gui/501/ai.openclaw.gateway
sleep 5
ps aux | grep -E "openclaw.*gateway" | grep -v grep   # PID changed; new process running fine on new dist/
RAW_BUFFERClick to expand / collapse

Bug type

Crash (process/app exits or hangs)

Beta release blocker

No

Summary

When npm install -g openclaw@<newver> runs while the openclaw gateway is alive, the new install replaces hash-suffixed chunk files in dist/ (e.g. legacy-config-issues-CClZWCli.jslegacy-config-issues-BxN-Pz1M.js). The running gateway process retains references to the old chunk hashes and on next config reload fails with ERR_MODULE_NOT_FOUND. Worse, the graceful shutdown path itself depends on a now-missing chunk (server-close-DsVPJDIx.js), so openclaw gateway restart --force cannot complete shutdown — only launchctl kickstart -k (or equivalent SIGKILL + respawn) recovers.

Steps to reproduce

  1. Have openclaw gateway running (e.g. as gui/501/ai.openclaw.gateway launchd agent).
  2. Run npm install -g openclaw@<any newer version where chunk hashes change> — the on-disk dist/*.js filenames change.
  3. Trigger any config reload (openclaw doctor --fix, save to openclaw.json, etc.).
  4. Observe Cannot find module .../legacy-config-issues-<oldhash>.js repeating in ~/.openclaw/logs/gateway.err.log.
  5. Run openclaw gateway restart --force → emits [gateway] shutdown error: Cannot find module .../server-close-<oldhash>.js. Old process never exits.
  6. Recovery requires launchctl kickstart -k gui/<uid>/ai.openclaw.gateway (SIGKILL + respawn).

Expected behavior

Either:

  • (a) The running gateway should resolve all chunk imports during startup and not lazy-import after that, so an in-place upgrade leaves the running process serving the old (in-memory) code until full restart; or
  • (b) The upgrade flow should be atomic from the gateway's perspective — full process exit before the new files land.

In any case, graceful shutdown should not depend on a chunk that may have been deleted: the shutdown handler itself should be resident in memory or eagerly imported at startup.

Actual behavior

Running gateway is left in a state where it can neither reload config nor shut itself down cleanly. Manual launchctl kickstart -k is the only recovery.

OpenClaw version

2026.5.3-beta.3 (upgraded in place from 2026.5.2)

Operating system

macOS 26.4.1 (arm64)

Install method

npm global

Model

openai-codex/gpt-5.5

Provider / routing chain

openclaw -> openai-codex

Logs, screenshots, and evidence

2026-05-04T11:08:17.896+08:00 [reload] config reload skipped (invalid config): : read failed: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/homebrew/lib/node_modules/openclaw/dist/legacy-config-issues-CClZWCli.js' imported from /opt/homebrew/lib/node_modules/openclaw/dist/io-BcjzQKwO.js
... (repeats every ~600ms in a flap loop)
2026-05-04T11:17:18.124+08:00 [reload] config change requires gateway restart (plugins.installs.brave)
2026-05-04T11:17:18.335+08:00 [gateway] SIGUSR1 restart ignored (not authorized; commands.restart=false or use gateway tool).
2026-05-04T11:17:18.522+08:00 [gateway] shutdown error: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/homebrew/lib/node_modules/openclaw/dist/server-close-DsVPJDIx.js' imported from /opt/homebrew/lib/node_modules/openclaw/dist/server.impl-B11albXx.js

The hashes the running process wanted are not in the new dist/:

$ ls /opt/homebrew/lib/node_modules/openclaw/dist/legacy-config-issues*.js
/opt/homebrew/lib/node_modules/openclaw/dist/legacy-config-issues-BxN-Pz1M.js
/opt/homebrew/lib/node_modules/openclaw/dist/legacy-config-issues-GeD6gJjS.js
# CClZWCli (the one the running process imported) is gone — was the previous version's hash

Recovery sequence that worked:

launchctl kickstart -k gui/501/ai.openclaw.gateway
sleep 5
ps aux | grep -E "openclaw.*gateway" | grep -v grep   # PID changed; new process running fine on new dist/

Impact and severity

  • Affected: anyone upgrading openclaw via npm install -g while the gateway is running (which is the documented happy path).
  • Severity: high — gateway is bricked into a no-shutdown state until manual SIGKILL.
  • Frequency: very likely on any version bump that produces new chunk hashes (effectively every release, since rollup/vite hashes are content-based).
  • Consequence: every npm-driven upgrade has a chance of leaving the user with a flapping, un-shutdown-able gateway, with confusing error messages that point at chunk filenames not at the upgrade itself.

Additional information

  • Last known good behavior: in 2026.5.1 era, npm install -g openclaw@<newver> followed by openclaw gateway restart --force was a normal upgrade flow without this bricked state. (The vite/rollup chunk-hash strategy may have been introduced or made more aggressive recently — not 100% confirmed from outside.)
  • Suggested mitigation paths:
    • Eager-import the shutdown path (or inline it) so gateway shutdown never touches the file system after startup.
    • Document launchctl kickstart -k (or platform equivalent) as the recommended in-place upgrade path, not gateway restart --force.
    • Have gateway restart --force detect missing-chunk errors and fall through to SIGKILL of the running PID itself.

extent analysis

TL;DR

The most likely fix is to modify the gateway to eager-import the shutdown path or inline it, ensuring that gateway shutdown never relies on file system access after startup.

Guidance

  • Identify and refactor the shutdown handler to be resident in memory or eagerly imported at startup, preventing dependence on potentially deleted chunks.
  • Consider documenting launchctl kickstart -k (or platform equivalent) as the recommended in-place upgrade path instead of gateway restart --force.
  • Implement a detection mechanism in gateway restart --force to catch missing-chunk errors and fall back to SIGKILL of the running PID.
  • Review the upgrade flow to ensure it is atomic from the gateway's perspective, allowing for a clean shutdown before new files are installed.

Example

No code snippet is provided due to the lack of specific implementation details in the issue.

Notes

The suggested mitigation paths aim to address the root cause of the issue. However, the effectiveness of these suggestions may depend on the specific implementation details of the openclaw gateway and its dependencies.

Recommendation

Apply the workaround by documenting launchctl kickstart -k (or platform equivalent) as the recommended in-place upgrade path, as this provides a reliable recovery method until a more permanent fix can be implemented.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Either:

  • (a) The running gateway should resolve all chunk imports during startup and not lazy-import after that, so an in-place upgrade leaves the running process serving the old (in-memory) code until full restart; or
  • (b) The upgrade flow should be atomic from the gateway's perspective — full process exit before the new files land.

In any case, graceful shutdown should not depend on a chunk that may have been deleted: the shutdown handler itself should be resident in memory or eagerly imported at startup.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug] gateway can't recover from npm chunk-hash replacement during in-place upgrade — graceful shutdown depends on now-missing chunk [3 comments, 3 participants]