Skip to content

Gateway crash: SyntaxError on bundled provider-discovery.runtime.js export n after in-place upgrade (2026.5.28) #88857

Closed as not planned

Description

@askgvt-bot

Summary

Gateway crashed with an unhandled SyntaxError claiming ./provider-discovery.runtime.js does not export n, even though the export is present in the bundled file. Appears to be an ESM module-cache / hot-reload race after an in-place dist update (npm/pnpm upgrade replacing files under a running process).

Version / environment

  • OpenClaw: 2026.5.28 (/opt/homebrew/lib/node_modules/openclaw, pnpm install path)
  • Node: v25.6.0
  • OS: macOS 15.6 (arm64)
  • Install: LaunchAgent openclaw.gateway (auto-restarted by launchd)

Error

From ~/.openclaw/logs/gateway.err.log at 2026-05-31T18:31:59-07:00:

[openclaw] Unhandled promise rejection: file:///opt/homebrew/lib/node_modules/openclaw/dist/provider-runtime-Cp-fJ4cK.js:13
import { n as resolvePluginDiscoveryProvidersRuntime } from "./provider-discovery.runtime.js";
         ^
SyntaxError: The requested module './provider-discovery.runtime.js' does not provide an export named 'n'
    at ModuleJob.#asyncInstantiate (node:internal/modules/esm/module_job:319:21)
    at processTicksAndRejections (node:internal/process/task_queues:104:5)
    at ModuleJob.run (node:internal/modules/esm/module_job:422:5)
    at onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:655:26)

Stability bundle written: ~/.openclaw/logs/stability/openclaw-stability-2026-06-01T01-31-59-310Z-62747-unhandled_rejection.json.

Why this is weird

The dist file does export n. Last line of dist/provider-discovery.runtime-D6oiOra8.js:

export { resolvePluginDiscoveryProvidersRuntime as n, clearProviderDiscoveryModuleLoaders as t };

And dist/provider-discovery.runtime.js is just a barrel re-export:

export * from "./provider-discovery.runtime-D6oiOra8.js";

So statically the import in provider-runtime-Cp-fJ4cK.js line 13 should resolve fine. The fact that Node's ESM linker disagrees at runtime suggests either:

  1. Race during in-place upgrade: dist files were rewritten under the running process and Node cached a stale module record for provider-discovery.runtime.js before the barrel re-export was finalized.
  2. Hot-reload module-cache invalidation bug: clearNativeRequireJavaScriptModuleCache / getCachedPluginModuleLoader (referenced in provider-discovery.runtime-D6oiOra8.js) cleared a require() cache entry but not a corresponding ESM module record, leaving an inconsistent view.
  3. TOCTOU on the barrel file: provider-discovery.runtime.js was read while it still contained an older export * target that didn't have the renamed n symbol.

All dist files have mtime May 31 17:01 and the crash was at 18:31 — ~90 minutes after the update, but the process had been running across the upgrade.

Knock-on effects

The crash itself isn't catastrophic, but the next gateway startup (auto-relaunch by launchd at 2026-06-01T01:32:11Z) failed with:

Invalid config at /Users/.../openclaw.json. bindings.2.agentId: Unknown agent id "ruby" (not in agents.list). Run "openclaw doctor --fix" to repair, then retry.

That's a separate validation tightening in 2026.5.28 (good!), but the config auto-migration written at the time of the crash kept a binding for an agent id (ruby) whose agentDir entry under agents.subagents had already been dropped by a prior migration. So 2026.5.28 left the config in a self-inconsistent state on startup. openclaw doctor --fix cleaned it.

Suggestion: when migrating agents.subagents, the same pass should drop any bindings[].agentId (and channel accounts[].agentId) that no longer resolve.

Repro signal

Hard to repro deterministically (it's a race), but a probable trigger is:

  1. Run gateway under launchd (long-lived).
  2. pnpm i -g openclaw@latest (or whatever the auto-updater path is) while it's running, replacing files under dist/ in place.
  3. Wait for any code path that re-imports provider-discovery.runtime.js via the plugin loader cache.

Attachments

Happy to upload the full stability bundle (~220 KB JSON) if useful — it's redacted of host name but contains capability/loader snapshot. Reply and I'll attach.

Workaround

openclaw doctor --fix followed by gateway restart. Already back to healthy on this host.

Activity

  1. clawsweeper commented on Jun 1, 2026

    @clawsweeper
    Contributor

    Thanks for writing this up. I checked the repo boundary, and this lives outside the OpenClaw source shell.

    This can close because the crash path comes from replacing the installed package tree while a managed Gateway is still running, and current OpenClaw's supported package updater already stops the managed service before the package update and blocks package updates from inside the Gateway service process.

    So I’m closing this as outside the OpenClaw source repository rather than keeping it open as core work.

    Review details

    Best possible solution:

    Keep the supported openclaw update and openclaw doctor --fix paths as canonical; manual global package replacement should stop the Gateway first and restart after doctor repair if config validation fails.

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

    No; the report itself says the ESM export failure is a hard-to-reproduce race, and the source-backed supported updater path already avoids replacing the package tree under a live managed Gateway.

    Is this the best way to solve the issue?

    Yes; the best maintainable solution is to keep package replacement behind the supported updater or require users to stop the Gateway before manual global package installs, with openclaw doctor --fix owning stale config repair.

    Security review:

    Security review: This is an issue triage review with no proposed patch or supply-chain diff to inspect.

    AGENTS.md: found and applied where relevant.

    What I checked:

    • Repository policy read: Root AGENTS.md was read from disk and applied; the relevant guidance treats setup/startup/config loading and provider routing as compatibility-sensitive, and prefers current supported update and doctor paths over runtime compatibility shims. (AGENTS.md:1, 72bc9ae95231)
    • Issue report context: The report describes a v2026.5.28 LaunchAgent install where pnpm i -g openclaw@latest likely replaced dist/ under a long-running Gateway, producing an ESM named-export SyntaxError; the reporter already recovered by running openclaw doctor --fix and restarting.
    • Supported updater stops the managed Gateway first: The package update path calls maybeStopManagedServiceBeforePackageUpdate before running the package-manager update, and that helper stops a running managed Gateway service when restart is enabled. (src/cli/update-cli/update-command.ts:3308, 72bc9ae95231)
    • Updater blocks unsafe self-update from Gateway service: Current code rejects package updates from inside the Gateway service process because that would replace the active dist tree while the live Gateway may still lazy-load old chunks. (src/cli/update-cli/update-command.ts:3333, 72bc9ae95231)
    • Manual package-install guidance already names the safe path: The update error guidance tells users doing a sudo/manual package install on a managed Gateway to stop the Gateway first, then reinstall and restart. (src/cli/update-cli/progress.ts:89, 72bc9ae95231)
    • Stale top-level binding repair exists: Doctor compatibility repair prunes bindings[] entries whose agentId is not present in a valid agents.list, and the adjacent regression test covers the stale-binding case. (src/commands/doctor/shared/legacy-config-core-migrate.ts:12, 72bc9ae95231)

    Likely related people:

    • Gio Della-Libera: Current shallow history for the update/package, provider-discovery, and doctor/config repair surfaces points to this commit as the latest broad touch in the relevant files. (role: recent area contributor; confidence: medium; commits: bf777b9af29d; files: src/cli/update-cli/update-command.ts, src/plugins/provider-discovery.runtime.ts, src/commands/doctor/shared/legacy-config-core-migrate.ts)
    • Peter Steinberger: The latest release boundary is tied to e932160, and older binding/config history includes Peter-authored routing and binding cleanup commits. (role: release and config-routing adjacent contributor; confidence: medium; commits: e93216080aa1, 08f16da8d734; files: src/cli/update-cli/update-command.ts, src/commands/doctor/shared/legacy-config-core-migrate.ts, src/config/zod-schema.ts)
    • Tak Hoffman: Recent binding and routing history includes multiple Tak-authored fixes around preserving and resolving bindings, making them a useful routing candidate if maintainers revisit stale binding cleanup. (role: adjacent routing/binding contributor; confidence: low; commits: d50526dddc72, fa56682b3ced; files: src/config, src/channels)

    Codex review notes: model gpt-5.5, reasoning high; reviewed against 72bc9ae95231.

  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:crash-loopCrash, hang, restart loop, or process-level availability failure.
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    on Jun 1, 2026
  3. abhinas90 commented on Jun 1, 2026

    @abhinas90

    This sounds like a process lifecycle / session management failure, not just a one-off memory bug.

    Here's a diagnostic matrix to narrow it down:

    1. Check if it's single-session vs. cross-session accumulation

    ps aux | grep claude | awk '{print $2, $4, $6}' >> /tmp/claude-mem.log
    # Run your workload, then check if RSS grows linearly per task or exponentially over sessions
    

    2. Identify zombie processes (most common cause of phantom memory growth)

    ps aux | grep defunct
    # If you see [claude] <defunct>, the parent isn't reaping children
    # Known issue in some v1.x betas — check your CLI version
    

    3. Session isolation test

    for i in $(seq 1 5); do
      claude --print "hello world" && sleep 2
    done
    ps aux | grep claude
    # If memory after 5 is significantly > after 1, it's accumulation
    

    4. Quick mitigation while waiting for a patch
    If you're hitting this in automated workflows, wrap sessions with a watchdog:

    timeout 300 claude ... || kill -9 $(pgrep -f claude)
    

    I maintain production agent fleets (OpenClaw) and have a hardening checklist for session pooling, resource limits, and monitoring hooks if that would help.

  4. RomneyDa commented on Jun 9, 2026

    @RomneyDa
    Member

    Thanks for the detailed report. I rechecked this against current source and the published update docs, and I’m closing it as an unsupported/manual-update edge case rather than keeping it open as core Gateway work.

    The crash signature is consistent with replacing the installed OpenClaw package tree while an existing Gateway process is still alive. That leaves old, already-loaded chunks in memory while stable runtime boundary files on disk now point at a different build, so Node can report an apparently impossible ESM export mismatch such as provider-discovery.runtime.js not exporting n. Once the package tree has been replaced under a live process, there is not a reliable in-process repair path; the correct recovery is to restart onto one consistent build.

    The supported updater path already avoids this state: package-manager updates stop the managed Gateway before package replacement, block package updates from inside the Gateway service process, then restart and verify the updated Gateway version. The docs also cover the manual path explicitly: prefer openclaw update; if using npm/pnpm/bun manually on a supervised install, stop the managed Gateway before the package manager starts and restart it afterward. See https://docs.openclaw.ai/install/updating and https://docs.openclaw.ai/cli/update.

    The config fallout called out in the report is also covered by openclaw doctor --fix: current doctor compatibility repair prunes top-level bindings[] entries that reference missing agents.list ids, and the focused binding-repair regression test passes on current source.

    So the actionable guidance is: use openclaw update for supervised installs; for manual package-manager recovery, keep the Gateway stopped through the package replacement, restart after the install, and run openclaw doctor --fix if startup reports stale config. Since that behavior is already documented and handled by the supported paths, I’m closing this as not planned.

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

Metadata

Metadata

Assignees

Labels

P1High-priority user-facing bug, regression, or broken workflow.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions