openclaw - ✅(Solved) Fix 2026.4.12 npm package misses subagent-registry.runtime.js, causing subagent cleanup ERR_MODULE_NOT_FOUND [2 pull requests, 2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#66096Fetched 2026-04-14 05:39:07
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×3commented ×2referenced ×1

[email protected] is missing dist/subagent-registry.runtime.js in the published npm package, but dist/subagent-registry-CflSFWBm.js still tries to dynamically import it.

This causes repeated runtime warnings during subagent cleanup on macOS:

[warn] subagent cleanup finalize failed (...): Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry.runtime.js' imported from /opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry-CflSFWBm.js

I also previously saw a similar missing-runtime symptom for audit-membership-runtime-*.js, so this looks related to the recent lazy runtime packaging regressions.

Error Message

[warn] subagent cleanup finalize failed (...): Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry.runtime.js' imported from /opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry-CflSFWBm.js Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry.runtime.js'

Root Cause

[email protected] is missing dist/subagent-registry.runtime.js in the published npm package, but dist/subagent-registry-CflSFWBm.js still tries to dynamically import it.

This causes repeated runtime warnings during subagent cleanup on macOS:

[warn] subagent cleanup finalize failed (...): Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry.runtime.js' imported from /opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry-CflSFWBm.js

I also previously saw a similar missing-runtime symptom for audit-membership-runtime-*.js, so this looks related to the recent lazy runtime packaging regressions.

Fix Action

Fixed

PR fix notes

PR #66102: fix(build): pin subagent-registry.runtime as stable entry (#66096)

Description (problem / solution / changelog)

Summary

`[email protected]` ships without `dist/subagent-registry.runtime.js`, but the built `src/agents/subagent-registry.ts` still does `import("./subagent-registry.runtime.js")` at runtime. Subagent cleanup then fails with `ERR_MODULE_NOT_FOUND` on every run (#66096):

``` Cannot find module '.../dist/subagent-registry.runtime.js' imported from '.../dist/subagent-registry-CflSFWBm.js' ```

`tsdown.config.ts` already maintains an explicit allowlist of lazy runtime boundaries that must be emitted on stable filenames so the downstream `writeStableRootRuntimeAliases` postbuild step (in `scripts/runtime-postbuild.mjs`) can generate the `*.runtime.js` re-export shim. The `subagent-registry` runtime was missing from that list, so tsdown folded it into an adjacent hashed chunk (`subagent-registry-<hash>.js`) and the shim generator had nothing matching `<base>.runtime-<hash>.js` to alias from.

This PR adds `agents/subagent-registry.runtime` to the entries block alongside the other `agents/*.runtime` boundaries (`auth-profiles`, `model-catalog`, `models-config`, etc.) so the built tree contains both `dist/agents/subagent-registry.runtime-<hash>.js` and `dist/subagent-registry.runtime.js` going forward.

This matches the pattern used for the previous missing-runtime fixes referenced in the issue: #65561, #65735, #65962.

Closes #66096.

Changes

  • `tsdown.config.ts` — add `"agents/subagent-registry.runtime": "src/agents/subagent-registry.runtime.ts"` to `buildCoreDistEntries()` alphabetically next to the other `agents/` runtime entries (1-line insertion)

Test plan

  • Mirrors the existing pattern for `auth-profiles.runtime`, `model-catalog.runtime`, `models-config.runtime`, which all currently ship correctly
  • Source file `src/agents/subagent-registry.runtime.ts` already exists
  • The only runtime caller (`src/agents/subagent-registry.ts:121`) uses the `./subagent-registry.runtime.js` relative path which the stable-alias postbuild step resolves
  • A CI build-smoke that greps `dist/` for `subagent-registry.runtime.js` would catch similar regressions — can be a follow-up, not included here to keep the diff minimal

🤖 Generated with Claude Code

Changed files

  • tsdown.config.ts (modified, +1/-0)

PR #66276: fix(cli): prevent process hang after gateway RPC commands (#66227)

Description (problem / solution / changelog)

Summary

Fixes #66227 — CLI commands (cron list, agents list, etc.) hang indefinitely after printing their result.

Root cause: executeGatewayRequestWithScopes calls client.stop() (fire-and-forget) after the RPC response arrives. This issues ws.close() but does not wait for the server's close frame. The underlying TCP socket remains ref'd until either the server responds or the 250 ms ws.terminate() grace timer fires. Since runCli() returns without process.exit(), any handle that outlives the command stalls the event loop indefinitely.

The regression in 2026.4.12 likely widened this window (Gateway-side close behavior change, tick interval change, or new ref'd handles introduced in that release).

Changes

src/cli/run-main.ts

Add process.exit(process.exitCode ?? 0) at the end of runCli(), after closeCliMemoryManagers() completes in the finally block.

  • All async cleanup runs before the call
  • process.once('exit', ...) handlers are synchronous and still fire normally (verified: finalizeDebugProxyCapture is sync)
  • Makes CLI exit deterministic regardless of which handles outlive the command

src/gateway/client.ts

Call tickTimer.unref() immediately after the setInterval in startTickWatch().

  • beginStop() already calls clearInterval(tickTimer) on the normal close path — this is unchanged
  • unref() is defence-in-depth for any path where clearInterval is not reached before the process would otherwise exit naturally (e.g. uncaught error before beginStop)
  • No effect on the Gateway server process (server has its own lifecycle management)

Safety analysis

  • process.once('exit') in run-main.ts (line 178): calls finalizeDebugProxyCapture() — synchronous SQLite flush + fetch patch removal. Fires correctly via process.exit(). ✅
  • No other process.on('exit') or process.on('beforeExit') registrations found in src/cli/. ✅
  • stopAndWait() was considered and rejected: awaiting a close-frame-dependent promise inside onHelloOk's callback stack has awkward timing and is redundant given the process.exit() in runCli(). ✅

Testing

Manual verification: openclaw cron list and openclaw agents list exit immediately after output. No behaviour change for error paths (already called process.exit(1)).

AI Disclosure

  • AI-assisted (Claude Code via OpenClaw)
  • Root cause traced through full call chain: runCliprogram.parseAsynccallGatewayFromCliexecuteGatewayRequestWithScopesGatewayClient
  • Exit handler audit performed before adding process.exit()
  • Understands what the code does — minimal targeted fix, no architecture change

Changed files

  • src/entry.ts (modified, +5/-1)
  • src/gateway/client.ts (modified, +5/-0)
  • src/index.ts (modified, +8/-5)
  • src/infra/exit-after-flush.ts (added, +28/-0)

Code Example

[warn] subagent cleanup finalize failed (...): Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry.runtime.js' imported from /opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry-CflSFWBm.js

---

ls /opt/homebrew/lib/node_modules/openclaw/dist | grep subagent-registry.runtime
# no result

---

/opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry-CflSFWBm.js:2509
const SUBAGENT_REGISTRY_RUNTIME_SPEC = ["./subagent-registry.runtime", ".js"];

---

node -e 'import(new URL("./subagent-registry.runtime.js", "file:///opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry-CflSFWBm.js").href)'

---

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry.runtime.js'
RAW_BUFFERClick to expand / collapse

Summary

[email protected] is missing dist/subagent-registry.runtime.js in the published npm package, but dist/subagent-registry-CflSFWBm.js still tries to dynamically import it.

This causes repeated runtime warnings during subagent cleanup on macOS:

[warn] subagent cleanup finalize failed (...): Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry.runtime.js' imported from /opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry-CflSFWBm.js

I also previously saw a similar missing-runtime symptom for audit-membership-runtime-*.js, so this looks related to the recent lazy runtime packaging regressions.

Environment

  • OpenClaw: 2026.4.12 (1c0672b)
  • Install method: global npm install
  • Platform: macOS
  • Install path: /opt/homebrew/lib/node_modules/openclaw

What I verified

  1. The installed package does not contain the runtime file:
ls /opt/homebrew/lib/node_modules/openclaw/dist | grep subagent-registry.runtime
# no result
  1. The built file still references that runtime path:
/opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry-CflSFWBm.js:2509
const SUBAGENT_REGISTRY_RUNTIME_SPEC = ["./subagent-registry.runtime", ".js"];
  1. The failure is reproducible directly:
node -e 'import(new URL("./subagent-registry.runtime.js", "file:///opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry-CflSFWBm.js").href)'

Result:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/homebrew/lib/node_modules/openclaw/dist/subagent-registry.runtime.js'
  1. I unpacked the published npm tarball for [email protected] and confirmed it also does not contain dist/subagent-registry.runtime.js.

Expected

Either:

  • publish dist/subagent-registry.runtime.js, or
  • stop referencing that path from subagent-registry-CflSFWBm.js

Impact

Gateway still runs, but subagent cleanup emits repeated runtime warnings and cleanup/finalization appears incomplete.

Related context

This looks similar to the recent missing lazy-runtime packaging fixes:

  • #39586
  • #54790
  • #65561
  • #65735
  • #65962

extent analysis

TL;DR

The issue can be resolved by either publishing the missing dist/subagent-registry.runtime.js file or updating the subagent-registry-CflSFWBm.js file to stop referencing the missing file.

Guidance

  • Verify that the dist/subagent-registry.runtime.js file is not present in the published npm package by checking the package contents.
  • Check the build process to ensure that the dist/subagent-registry.runtime.js file is being generated and included in the package.
  • Update the subagent-registry-CflSFWBm.js file to use a different import path or remove the reference to the missing file.
  • Test the updated package to ensure that the runtime warnings are resolved and subagent cleanup is completed successfully.

Example

No code snippet is provided as the issue is related to a missing file and not a code error.

Notes

The issue appears to be related to a packaging regression, and similar issues have been reported in the past (e.g., #39586, #54790, #65561, #65735, #65962). Resolving this issue may require updates to the build or packaging process.

Recommendation

Apply a workaround by updating the subagent-registry-CflSFWBm.js file to stop referencing the missing dist/subagent-registry.runtime.js file, as this is a more immediate solution than waiting for a new package version to be published.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING