Repository navigation
Description
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:
- Race during in-place upgrade: dist files were rewritten under the running process and Node cached a stale module record for
provider-discovery.runtime.jsbefore the barrel re-export was finalized. - Hot-reload module-cache invalidation bug:
clearNativeRequireJavaScriptModuleCache/getCachedPluginModuleLoader(referenced inprovider-discovery.runtime-D6oiOra8.js) cleared arequire()cache entry but not a corresponding ESM module record, leaving an inconsistent view. - TOCTOU on the barrel file:
provider-discovery.runtime.jswas read while it still contained an olderexport *target that didn't have the renamednsymbol.
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:
- Run gateway under launchd (long-lived).
pnpm i -g openclaw@latest(or whatever the auto-updater path is) while it's running, replacing files underdist/in place.- Wait for any code path that re-imports
provider-discovery.runtime.jsvia 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.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 1, 2026
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 updateandopenclaw doctor --fixpaths 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 --fixowning 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:
AGENTS.md:1, 72bc9ae95231)pnpm i -g openclaw@latestlikely replaceddist/under a long-running Gateway, producing an ESM named-export SyntaxError; the reporter already recovered by runningopenclaw doctor --fixand restarting.maybeStopManagedServiceBeforePackageUpdatebefore 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)src/cli/update-cli/update-command.ts:3333, 72bc9ae95231)src/cli/update-cli/progress.ts:89, 72bc9ae95231)bindings[]entries whoseagentIdis not present in a validagents.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:
src/cli/update-cli/update-command.ts,src/plugins/provider-discovery.runtime.ts,src/commands/doctor/shared/legacy-config-core-migrate.ts)src/cli/update-cli/update-command.ts,src/commands/doctor/shared/legacy-config-core-migrate.ts,src/config/zod-schema.ts)src/config,src/channels)Codex review notes: model gpt-5.5, reasoning high; reviewed against 72bc9ae95231.
abhinas90 commentedon Jun 1, 2026
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
2. Identify zombie processes (most common cause of phantom memory growth)
3. Session isolation test
4. Quick mitigation while waiting for a patch
If you're hitting this in automated workflows, wrap sessions with a watchdog:
I maintain production agent fleets (OpenClaw) and have a hardening checklist for session pooling, resource limits, and monitoring hooks if that would help.
RomneyDa commentedon Jun 9, 2026
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.jsnot exportingn. 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 usingnpm/pnpm/bunmanually 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-levelbindings[]entries that reference missingagents.listids, and the focused binding-repair regression test passes on current source.So the actionable guidance is: use
openclaw updatefor supervised installs; for manual package-manager recovery, keep the Gateway stopped through the package replacement, restart after the install, and runopenclaw doctor --fixif startup reports stale config. Since that behavior is already documented and handled by the supported paths, I’m closing this as not planned.