Skip to content

[Bug] Stale plugin-runtime-deps causes Gateway crash-loop after openclaw update #73520

Closed

Description

@kingkong9817

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:

  1. 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.

  2. 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 its dist/ 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 update doesn'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

Evidence:

  • gateway.err.log jumps 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:

  1. After npm install completes, scan plugin-runtime-deps/
  2. Recognize directory naming pattern openclaw-{version}-{hash} or openclaw-unknown-{hash}
  3. Call resolveBinaryVersion() to get the current installed version
  4. Remove directories whose version doesn't match (keep openclaw-unknown-*)
  5. Log which directories were cleaned up
  6. 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 start

Activity

  1. clawsweeper commented on Apr 29, 2026

    @clawsweeper
    Contributor

    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:

    Likely related people:

    • vincentkoc: Vincent's current-main commit introduced the legacy runtime-deps root pruning implementation, its regression test, and the changelog/docs note; the issue timeline also shows he was mentioned and subscribed for this runtime-deps follow-up. (role: fix author / runtime-deps follow-up owner; confidence: high; commits: 465d1b0d4ba3, 637525136ed9; files: src/plugins/bundled-runtime-deps-roots.ts, src/plugins/bundled-runtime-deps.ts, src/plugins/bundled-runtime-deps.test.ts)
    • steipete: Peter carried the adjacent runtime-deps repair simplification and several package-update restart hardening commits that are part of the current-main behavior around this report. (role: recent runtime-deps and update maintainer; confidence: high; commits: 250376f88577, 29ed5266bf0a, e131eaecb502; files: 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.

  2. locked as resolved and limited conversation to collaborators on May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions