Skip to content

Module Not Found After Upgrading to 2026.5.2 (ERR_MODULE_NOT_FOUND) #76425

Closed

Description

@visionzhang-prog
  1. Environment
    OS: macOS (Apple Silicon / m2)
    Node Version: v22.22.2 (managed via fnm)
    OpenClaw Version: 2026.5.2
    Package Manager: npm
  2. Problem Description

After upgrading to OpenClaw 2026.5.2, the Gateway process starts, but core functionalities (including Feishu, DingTalk, and internal dispatch/runtime) crash immediately with ERR_MODULE_NOT_FOUNDerrors.

The root cause appears to be stale hashed runtime artifacts. The running Gateway process attempts to import JavaScript files with old hash suffixes (e.g., -CtxgXAPs) that no longer exist after the upgrade overwrote the dist/directory.

  1. Steps to Reproduce
    Ensure Node version is v22.22.2 using fnm.
    Upgrade OpenClaw globally:
    npm install -g openclaw@2026.5.2
    Start the gateway:
    openclaw start
    Send a test message via Feishu or DingTalk, or observe initialization logs.
  2. Observed Behavior & Logs (Sanitized)

The logs consistently show failures to resolve paths containing hashed filenames within the ~/.local/share/fnm/.../openclaw/dist/directory.

Example Errors:
Feishu Channel Dispatch Failure:
error gateway/channels/feishu feishu[default]: failed to dispatch message: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/[USER]/.../openclaw/dist/reply-media-paths.runtime-CtxgXAPs.js' imported from .../dist/dispatch-DGQApgF3.js
General Inbound Runtime Failure:
error channels/feishu Cannot find module '/Users/[USER]/.../openclaw/dist/inbound.runtime-By6GtcRw.js'
DingTalk SDK Dispatch Failure:
error [DingTalk:default] SDK dispatch failed: Cannot find module '/Users/[USER]/.../openclaw/dist/reply-media-paths.runtime-CtxgXAPs.js'
5. Expected Behavior

The gateway should correctly regenerate all runtime assets upon upgrade. A simple restart (openclaw start) should not result in MODULE_NOT_FOUNDerrors caused by stale file references.

  1. Temporary Workaround

Manually killing all Node processes and clearing runtime caches resolves the issue until the next upgrade:
pkill -f openclaw
pkill -f node
rm -rf ~/.openclaw/plugin-runtime-deps
npm uninstall -g openclaw
npm install -g openclaw@2026.5.2
openclaw start
7. Additional Context

This issue was not observed in version 2026.4.25. The problem seems related to the upgrade mechanism between 2026.4.x and 2026.5.x not properly handling the regeneration of runtime assets while the gateway is running.

Activity

  1. clawsweeper commented on May 3, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

    Current main and the latest release now cover the stale live-Gateway and mixed-dist upgrade failure family well enough to close: update work is handed off outside the live Gateway, npm global updates are staged and verified before swap, and restart paths are hardened against rotated hashed chunk imports.

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review details

    Best possible solution:

    Keep the current managed update handoff and staged package-swap implementation, and ask for a new narrow report only if v2026.6.6 or newer still reproduces stale chunk imports after upgrade.

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

    Yes from source and field reports, but not by running a live global package upgrade in this read-only review. The stale Gateway version mismatch and missing hashed chunks match the current source comments and tests for rotated dist imports.

    Is this the best way to solve the issue?

    Yes. The current implementation fixes the right boundary by avoiding live package-tree mutation, staging and verifying package updates, and respawning the Gateway instead of adding per-channel import fallbacks.

    Security review:

    Security review: No patch security review applies; this is an ordinary issue triage for update/runtime availability.

    AGENTS.md: found and applied where relevant.

    What I checked:

    • Current Gateway restart source: The Gateway loop eagerly resolves the lifecycle runtime before signal handlers so rotated dist chunk hashes after an in-place package upgrade cannot cause the scheduled update restart path to fail with ERR_MODULE_NOT_FOUND and leave the Gateway alive on old chunks. (src/cli/gateway-cli/run-loop.ts:111, 7e12a3326dd2)
    • Current update handoff source: update.run detects global and supervised git install surfaces and uses a managed-service handoff so the running Gateway does not replace its own package or built dist tree while still serving RPCs. (src/gateway/server-methods/update.ts:174, 7e12a3326dd2)
    • Current staged package update source: Global package updates install into a staged npm prefix, verify the candidate package tree, then swap the clean tree into the live global root instead of overlaying stale files in place. (src/infra/package-update-steps.ts:586, 7e12a3326dd2)
    • Legacy chunk compatibility source: The postbuild script writes stable runtime aliases and explicit compatibility aliases for published hashed chunks from the affected v2026.4.29, v2026.5.2, v2026.5.3, and v2026.5.4 upgrade window. (scripts/runtime-postbuild.mjs:28, 7e12a3326dd2)
    • Regression tests: Tests cover managed package handoff instead of in-process update, hard respawn of update restarts, staged npm prefix swap, and release-check rejection of old self-swapped process import misses. (src/gateway/server-methods/update.test.ts:397, 7e12a3326dd2)
    • User-facing docs: The update docs now warn manual package-manager users to stop the managed Gateway before replacing files and describe the OpenClaw-managed staged npm install, dist verification, and service restart behavior. Public docs: docs/install/updating.md. (docs/install/updating.md:111, 7e12a3326dd2)

    Likely related people:

    • Peter Steinberger: Recent commits force package update restart handoff, bypass update restart cooldown, and keep legacy lazy chunks importable after updates in the affected update/runtime area. (role: recent update/restart contributor; confidence: high; commits: e131eaecb502, 88da533714e5, 88943e14f92e; files: src/gateway/server-methods/update.ts, scripts/runtime-postbuild.mjs)
    • Samuel Rodda: Commit 6c252cc introduced the applied Gateway restart behavior that the current update path builds on. (role: introduced restart behavior; confidence: medium; commits: 6c252cc54c3c; files: src/cli/gateway-cli/run-loop.ts, src/gateway/server-methods/update.ts)
    • Vincent Koc: Current blame on the exact lifecycle priming and managed handoff lines points to 37e3e89, and the latest release SHA also carries the current implementation. (role: current release-area contributor; confidence: medium; commits: 37e3e895b020, 8c802aa68351; files: src/cli/gateway-cli/run-loop.ts, src/gateway/server-methods/update.ts, src/infra/package-update-steps.ts)

    Codex review notes: model internal, reasoning high; reviewed against 7e12a3326dd2; fix evidence: release v2026.6.6, commit 8c802aa68351.

  2. apex-system commented on May 11, 2026

    @apex-system

    Field update from a local macOS/Homebrew install on 2026.5.7.

    Observed failure before repair:

    • OpenClaw package was installed at 2026.5.7, but the running LaunchAgent Gateway still reported self version 2026.5.6.
    • Gateway RPC handlers failed with stale hashed chunk imports, including bash-tools-BvsIc29z.js, task-registry.maintenance-CvTYvEjK.js, status.link-channel-C7zLFzlT.js, and secrets-BXw8r2d-.js.
    • Slack config/status checks were blocked by those stale imports.

    Repair path that worked:

    • openclaw gateway restart --safe --json was accepted, but joined an existing pending restart and did not reload the stale PID.
    • openclaw gateway restart --force --json killed the stale Gateway PID and relaunched the LaunchAgent.

    Post-restart proof:

    • openclaw gateway status showed a new Gateway PID listening on 127.0.0.1:18789.
    • Fresh openclaw status --json reported runtime/self version 2026.5.7 and no secret diagnostics.
    • Fresh openclaw channels status --json --probe reported Slack running: true, connected: true, healthState: healthy, and probe ok: true / HTTP 200.
    • Logs after restart showed gateway ready and slack socket mode connected.

    Notes:

    • This supports the stale-live-process explanation for package updates that replace dist/ while an old Gateway process remains alive.
    • In this case, a normal/safe restart request was not sufficient; a force restart was needed to clear the old process.
    • I did not verify a real inbound Slack message in this run, only Gateway health, Slack socket connection, and Slack API probe.
  3. apex-system commented on May 11, 2026

    @apex-system

    Follow-up from the same machine after the stale-dist restart fix.

    Observed a separate failure mode from Slack after local exec tools completed successfully:

    • Local exec commands finished and Slack showed the tool completion.
    • The final assistant reply then failed with: The model did not produce a response before the model idle timeout...
    • Gateway logs showed Profile google:default timed out and embedded_run_failover_decision ... fallbackConfigured=false ... provider=google model=gemini-2.5-flash.
    • Attempting to add openai/gpt-5.5 as a fallback was not safe on this host because the opopenai secret provider can time out during Gateway startup. I removed that fallback so startup is not blocked by an unavailable OpenAI secret.
    • Set agents.defaults.timeoutSeconds to 600 as a safer host-level mitigation for the current Google primary model.

    Verification after restart:

    • Gateway restarted cleanly and is reachable on 127.0.0.1:18789.
    • Runtime version: 2026.5.7.
    • Slack socket mode reconnected and channels status --probe reports Slack probe HTTP 200.
    • Non-delivered diagnostic agent turn against google/gemini-2.5-flash returned PONG in ~4.7s.

    Remaining risk:

    • This does not prove a real inbound Slack message end-to-end; it proves Gateway, Slack probe, and a direct agent/model turn.
    • The host still depends on 1Password exec secret providers (op*) during cold startup, and those have previously timed out at 30s. That is likely a separate durability issue.
  4. IgnacioPro commented on May 13, 2026

    @IgnacioPro

    I hit what looks like the same stale-hash / mixed-dist family on Linux x64, but the visible symptom is Telegram message.action=send failing locally before any provider call.

    New issue with full evidence: #81461

    Key details from this repro:

    • openclaw --version = 2026.5.3 (06d46f7)
    • openclaw status still reports Gateway self ... app 2026.5.2
    • message tool error: Cannot find module '/usr/lib/node_modules/openclaw/dist/action-runtime-JVgOnJIQ.js' imported from /usr/lib/node_modules/openclaw/dist/probe-gofM6JmN.js
    • those exact files are missing on disk, while sibling hashed chunks exist (action-runtime-CYqPrZR6.js, probe-DoAxOwuy.js)
    • controlled restart + manual restart did not clear it

    So this is not just inbound/runtime boot; it is also breaking outbound tool-driven message delivery.

  5. barnacle-openclaw commented on May 30, 2026

    @barnacle-openclaw

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  6. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:crash-loopCrash, hang, restart loop, or process-level availability failure.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    on Jun 14, 2026
  7. locked as resolved and limited conversation to collaborators on Jun 25, 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

    P1High-priority user-facing bug, regression, or broken workflow.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions