openclaw - 💡(How to fix) Fix [Bug] Gateway crashes during npm upgrade - SIGUSR1 arrives before files are written [1 comments, 2 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#72104Fetched 2026-04-27 05:34:48
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Timeline (top)
closed ×1commented ×1

Error Message

Gateway failed to start: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/tim/.npm-global/lib/node_modules/openclaw/dist/server-startup-log-B9JxhIZA.js'

Root Cause

Gateway crashes and enters a restart loop during npm install -g openclaw@latest because the SIGUSR1 hot-restart signal arrives while npm is still writing new package files, causing ERR_MODULE_NOT_FOUND errors.

Code Example

Gateway failed to start: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/tim/.npm-global/lib/node_modules/openclaw/dist/server-startup-log-B9JxhIZA.js'

---

// Current (buggy): parallel execution
await exec(npm install);  // runs in background
send SIGUSR1;             // fires immediately

// Fixed: sequential
await exec(npm install);  // waits for completion
await sleep(5);           // brief safety buffer
send SIGUSR1;             // safe to restart
RAW_BUFFERClick to expand / collapse

Bug Description

Gateway crashes and enters a restart loop during npm install -g openclaw@latest because the SIGUSR1 hot-restart signal arrives while npm is still writing new package files, causing ERR_MODULE_NOT_FOUND errors.

Steps to Reproduce

  1. Run openclaw update.run (or npm install -g openclaw@latest && openclaw gateway restart)
  2. Observe Gateway enters crash loop immediately after

Actual Behavior

Gateway failed to start: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/tim/.npm-global/lib/node_modules/openclaw/dist/server-startup-log-B9JxhIZA.js'

Timeline:

  • T+0: npm install starts writing new files (~467 packages)
  • T+7min: Gateway receives SIGUSR1, attempts hot restart
  • T+7min to T+56min: Gateway repeatedly fails with ERR_MODULE_NOT_FOUND
  • T+56min+: npm install finally finishes, Gateway starts successfully

Expected Behavior

Gateway should only restart AFTER npm install completes, not during the file-write phase. Either:

  1. Option A (recommended): update.run should wait for npm install to complete before sending SIGUSR1
  2. Option B: Add a pre-flight check in gateway startup that verifies all expected dist/ files exist before loading

Environment

  • OpenClaw: 2026.4.23 → 2026.4.24
  • Node.js: v24.14.1
  • OS: Linux 6.17.0-22-generic (Ubuntu)
  • npm packages: 467 updated during upgrade

Suggested Fix (Option A)

In update.run, the npm install and SIGUSR1 should be sequential, not parallel:

// Current (buggy): parallel execution
await exec(npm install);  // runs in background
send SIGUSR1;             // fires immediately

// Fixed: sequential
await exec(npm install);  // waits for completion
await sleep(5);           // brief safety buffer
send SIGUSR1;             // safe to restart

Or use npm's --install-links flag to ensure atomic file replacement.

extent analysis

TL;DR

The Gateway crash loop during npm install -g openclaw@latest can be fixed by modifying the update.run script to wait for npm install to complete before sending the SIGUSR1 signal.

Guidance

  • Modify the update.run script to execute npm install and SIGUSR1 sequentially, ensuring that the SIGUSR1 signal is only sent after npm install has completed.
  • Consider adding a brief safety buffer (e.g., await sleep(5)) after npm install to account for any potential delays.
  • Alternatively, explore using npm's --install-links flag to achieve atomic file replacement and prevent the ERR_MODULE_NOT_FOUND error.
  • Verify the fix by running openclaw update.run and observing that the Gateway no longer enters a crash loop.

Example

The provided code snippet in the issue body demonstrates the modified update.run script:

await exec(npm install);  // waits for completion
await sleep(5);           // brief safety buffer
send SIGUSR1;             // safe to restart

Notes

This fix assumes that the issue is solely caused by the parallel execution of npm install and SIGUSR1. If other factors contribute to the crash loop, additional debugging may be necessary.

Recommendation

Apply the workaround by modifying the update.run script to execute npm install and SIGUSR1 sequentially, as this approach directly addresses the identified root cause of the issue.

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…

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 crashes during npm upgrade - SIGUSR1 arrives before files are written [1 comments, 2 participants]