Repository navigation
Closed
Closed
Copy link
Description
Bug: Stale plugin-runtime-deps directory causes Gateway crash-loop after openclaw update
Version Info
- Before: 2026.4.24
- After: 2026.4.26
- OS: macOS 26.4.1 (arm64), Node 25.9.0
- Install: npm global (
openclaw update)
Symptom
After running openclaw update, Gateway crashes and enters a launchd crash-loop for 5 hours, with no logs produced by the new process. Recovery required manually removing the old plugin-runtime-deps directory.
Root Cause (detailed data)
Timeline:
| Time (GMT+8) | Event |
|---|---|
| 13:08 | openclaw update runs, npm installs 2026.4.26 |
| 13:10:25 | Old Gateway process (v2026.4.24) receives SIGTERM |
| 13:10:26 | Old process reloads config, discovers bundled feishu/whatsapp plugins require >=2026.4.25 → version check fails → shutdown error |
| 13:10 ~ 18:12 | launchd repeatedly restarts new Gateway binary → process crashes before reaching logger output → launchd throttle puts it on ice for 5 hours |
| 18:12 | Manual gateway stop → mv old runtime-deps → gateway start → recovered |
Two-layer failure:
-
Old process version check failure: After update, the still-running v2026.4.24 Gateway reloads config, finds bundled feishu/whatsapp plugins from 2026.4.26 that require
>=2026.4.25, but the running host is 2026.4.24 → fatal config error → exit. -
New process crashes due to stale runtime-deps (the core bug): launchd starts the new v2026.4.26 binary, but
plugin-runtime-deps/now contains three directories:openclaw-2026.4.24-da6bdffc3d96/ ← old, 4009 JS files, full core code openclaw-2026.4.26-da6bdffc3d96/ ← new core deps, 3621 JS files openclaw-unknown-bd1f0b6280a9/ ← new channel layer deps, 3509 JS files- Lexicographic ordering:
2026.4.24<2026.4.26, so the old directory is scanned first - The old directory has no
package.json(runtime-deps only have.openclaw-runtime-deps.json), but itsdist/contains the full OpenClaw core modules (min-host-version,version, etc.) - 2026.4.26 introduced a layered runtime-deps architecture (previously a single flat directory), but
openclaw updatedoesn't clean up the old format directory - The new Gateway binary scans the old dist/ during startup → module loading conflict → crash at Node.js initialization stage, before the logger is even available
- Lexicographic ordering:
Evidence:
gateway.err.logjumps directly from 13:10:26 to 18:12:36 — no new process logs in between- macOS launchd shows
runs = 2(processes that exit within 10 seconds are classified as crashes, not counted as normal runs) - Manually removing the old directory immediately resolved the issue
- Old and new
dist/directories have many identically-named but different JS files (e.g.,min-host-version-xxx.js,version-xxx.js)
Proposed Fix
Add automatic cleanup to the openclaw update flow:
- After npm install completes, scan
plugin-runtime-deps/ - Recognize directory naming pattern
openclaw-{version}-{hash}oropenclaw-unknown-{hash} - Call
resolveBinaryVersion()to get the current installed version - Remove directories whose version doesn't match (keep
openclaw-unknown-*) - Log which directories were cleaned up
- Perform a hard restart (not old-process reload) to ensure the new binary starts fresh
Pseudo-code:
async function cleanupOldRuntimeDeps(currentVersion: string) {
const depsDir = path.join(configDir, 'plugin-runtime-deps');
const entries = await fs.readdir(depsDir);
for (const entry of entries) {
const match = entry.match(/^openclaw-(\d+\.\d+\.\d+)-/);
if (match && match[1] !== currentVersion) {
const fullPath = path.join(depsDir, entry);
await fs.rm(fullPath, { recursive: true });
log.info(`[update] cleaned up old runtime deps: ${entry}`);
}
}
}Temporary Workaround
openclaw gateway stop
find ~/.openclaw/plugin-runtime-deps/ -maxdepth 1 -type d \
-name "openclaw-*" ! -name "openclaw-$(openclaw --version | grep -oE '\d+\.\d+\.\d+')-*" \
! -name "openclaw-unknown-*" -exec rm -rf {} \;
openclaw gateway startReacted by clawsweeper
Reacted by clawsweeper
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Priority
None yet
Activity
clawsweeper commentedon Apr 29, 2026
Thanks for the context here. I did a careful shell check against current
main, and this is already implemented.Close as implemented on current main: the runtime-deps repair path now prunes stale legacy version-scoped roots, Gateway startup runs the same shared cleanup before plugin loading, and package updates use the updated install restart/verification path rather than relying on the old process. The fix is present on main but not yet in a tagged release.
So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review details
Best possible solution:
Keep the current shared cleanup and restart behavior on main, ship it in the next release, and track broader cache inspection/pruning UX separately from this crash-loop report.
Do we have a high-confidence way to reproduce the issue?
Yes. The current-main cleanup gap is now covered by a focused regression test that creates stale runtime-deps roots and asserts the intended removals; the original macOS launchd crash-loop was not replayed during this read-only review.
Is this the best way to solve the issue?
Yes. The current solution is broader and safer than an update-only deletion hook because the policy runs through shared Gateway startup and repair paths, preserves active locks, and keeps compatible previous roots limited to dependency node_modules reuse instead of old plugin dist imports.
Security review:
Security review: This is a non-PR reliability issue review; no patch or supply-chain diff is under review.
What I checked:
src/plugins/bundled-runtime-deps-roots.ts:169, 4cbd1b53cf86)src/plugins/bundled-runtime-deps.ts:401, 4cbd1b53cf86)src/gateway/server-startup-plugins.ts:78, 4cbd1b53cf86)src/plugins/bundled-runtime-deps.test.ts:3421, 4cbd1b53cf86)docs/plugins/dependency-resolution.md. (docs/plugins/dependency-resolution.md:166, 4cbd1b53cf86)src/cli/update-cli/update-command.ts:164, 4cbd1b53cf86)Likely related people:
src/plugins/bundled-runtime-deps-roots.ts,src/plugins/bundled-runtime-deps.ts,src/plugins/bundled-runtime-deps.test.ts)src/plugins/bundled-runtime-deps.ts,src/plugins/bundled-runtime-deps-roots.ts,src/gateway/server-startup-plugins.ts)Codex review notes: model gpt-5.5, reasoning high; reviewed against 4cbd1b53cf86; fix evidence: commit 465d1b0d4ba3, main fix timestamp 2026-05-01T01:18:13-07:00.