openclaw - ✅(Solved) Fix [Bug]: Bun runtime crashes on bootstrap — isDirectModuleNotFoundError does not recognize Bun error shape [1 pull requests, 1 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#69589Fetched 2026-04-22 07:50:31
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
cross-referenced ×1

Running bun openclaw.mjs crashes immediately with Cannot find module './dist/warning-filter.js' on v2026.3.22 and later. The isDirectModuleNotFoundError function in openclaw.mjs relies on Node-specific error properties (err.url, absolute path in err.message) that Bun does not provide, causing the optional warning-filter import to throw instead of being silently skipped.

Error Message

error: Cannot find module './dist/warning-filter.js' from '/path/to/openclaw/openclaw.mjs'

Bun v1.3.10 (Linux x64)

Root Cause

Running bun openclaw.mjs crashes immediately with Cannot find module './dist/warning-filter.js' on v2026.3.22 and later. The isDirectModuleNotFoundError function in openclaw.mjs relies on Node-specific error properties (err.url, absolute path in err.message) that Bun does not provide, causing the optional warning-filter import to throw instead of being silently skipped.

Fix Action

Fixed

PR fix notes

PR #69664: fix(bootstrap): recognize Bun error shape in isDirectModuleNotFoundError

Description (problem / solution / changelog)

Summary

Fixes bun openclaw.mjs crashing on bootstrap when the optional warning-filter import is missing.

Bun does not set err.url on ERR_MODULE_NOT_FOUND errors and uses the original relative specifier in its error message instead of a resolved absolute path. The existing isDirectModuleNotFoundError helper relied on Node-specific properties (err.url and absolute path in err.message), causing the catch block to re-throw on Bun instead of swallowing the expected optional-import miss.

Changes

  • openclaw.mjs: add Bun-aware check for err.specifier (Bun's ResolveMessage exposes the original import specifier here)
  • openclaw.mjs: add fallback message matching for relative specifiers so Bun's relative-path error messages are recognized

Type of change

  • Bug fix

Testing

  • pnpm format:check openclaw.mjs — passed
  • pnpm lint:core openclaw.mjs — 0 warnings, 0 errors
  • pnpm test src/infra/openclaw-root.test.ts — 9 passed
  • pnpm test test/openclaw-launcher.e2e.test.ts — 3 passed

Related Issue

Fixes #69589

Checklist

  • I have read the project contribution guidelines
  • My changes generate no new type errors in touched files
  • I have verified the fix addresses the reported issue

Changed files

  • openclaw.mjs (modified, +10/-1)

Code Example

git clone https://github.com/openclaw/openclaw.git && cd openclaw
git checkout v2026.4.19-beta.2   # or any version >= v2026.3.22
pnpm install && pnpm build && pnpm ui:build
bun openclaw.mjs --version

---

error: Cannot find module './dist/warning-filter.js' from '/path/to/openclaw/openclaw.mjs'

Bun v1.3.10 (Linux x64)

---

// Node ERR_MODULE_NOT_FOUND:
{ code: "ERR_MODULE_NOT_FOUND", url: "file:///abs/path/warning-filter.js", message: "Cannot find module '/abs/path/warning-filter.js' ..." }

// Bun ResolveMessage:
{ code: "ERR_MODULE_NOT_FOUND", specifier: "./dist/warning-filter.js", referrer: "/abs/path/openclaw.mjs", message: "Cannot find module './dist/warning-filter.js' ..." }

---

--- a/openclaw.mjs
+++ b/openclaw.mjs
@@ -56,10 +56,16 @@ const isDirectModuleNotFoundError = (err, specifier) => {
   }

   const expectedUrl = new URL(specifier, import.meta.url);
+  // Node sets err.url to the file URL of the missing module.
   if ("url" in err && err.url === expectedUrl.href) {
     return true;
   }

+  // Bun sets err.specifier to the original import specifier.
+  if ("specifier" in err && err.specifier === specifier) {
+    return true;
+  }
+
   const message = "message" in err && typeof err.message === "string" ? err.message : "";
   const expectedPath = fileURLToPath(expectedUrl);
   return (
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

Running bun openclaw.mjs crashes immediately with Cannot find module './dist/warning-filter.js' on v2026.3.22 and later. The isDirectModuleNotFoundError function in openclaw.mjs relies on Node-specific error properties (err.url, absolute path in err.message) that Bun does not provide, causing the optional warning-filter import to throw instead of being silently skipped.

Steps to reproduce

git clone https://github.com/openclaw/openclaw.git && cd openclaw
git checkout v2026.4.19-beta.2   # or any version >= v2026.3.22
pnpm install && pnpm build && pnpm ui:build
bun openclaw.mjs --version

Expected behavior

Prints version and exits, as it did on v2026.3.13-1 and earlier.

Actual behavior

error: Cannot find module './dist/warning-filter.js' from '/path/to/openclaw/openclaw.mjs'

Bun v1.3.10 (Linux x64)

OpenClaw version

v2026.3.22 through v2026.4.19-beta.2 (current)

Operating system

Ubuntu 24.04 (WSL2)

Install method

pnpm dev (from source)

Model

N/A (crashes before model resolution)

Provider / routing chain

N/A

Logs, screenshots, and evidence

Regression introduced by commit 092afc850d ("Bootstrap: report nested entry import misses"), first included in v2026.3.22. Last known good version: v2026.3.13-1.

The commit replaced isModuleNotFoundError (checks err.code === "ERR_MODULE_NOT_FOUND", works on both Node and Bun) with isDirectModuleNotFoundError, which checks:

  1. err.url === expectedUrl.href — Node sets err.url, Bun does not (undefined)
  2. err.message contains the resolved absolute path — Node uses absolute paths, Bun uses the original relative specifier

Both checks fail on Bun, so the catch block falls through to throw err.

Bun's ResolveMessage error object exposes a structured err.specifier property containing the original import specifier, which can be matched directly:

// Node ERR_MODULE_NOT_FOUND:
{ code: "ERR_MODULE_NOT_FOUND", url: "file:///abs/path/warning-filter.js", message: "Cannot find module '/abs/path/warning-filter.js' ..." }

// Bun ResolveMessage:
{ code: "ERR_MODULE_NOT_FOUND", specifier: "./dist/warning-filter.js", referrer: "/abs/path/openclaw.mjs", message: "Cannot find module './dist/warning-filter.js' ..." }

Suggested fix — add a Bun-compatible check using err.specifier (symmetric with the existing err.url check for Node):

--- a/openclaw.mjs
+++ b/openclaw.mjs
@@ -56,10 +56,16 @@ const isDirectModuleNotFoundError = (err, specifier) => {
   }

   const expectedUrl = new URL(specifier, import.meta.url);
+  // Node sets err.url to the file URL of the missing module.
   if ("url" in err && err.url === expectedUrl.href) {
     return true;
   }

+  // Bun sets err.specifier to the original import specifier.
+  if ("specifier" in err && err.specifier === specifier) {
+    return true;
+  }
+
   const message = "message" in err && typeof err.message === "string" ? err.message : "";
   const expectedPath = fileURLToPath(expectedUrl);
   return (

Verified on Bun 1.3.10: bun openclaw.mjs --version and bun openclaw.mjs --help both work after the fix. Node behavior unchanged.

Impact and severity

  • Affected: all users running OpenClaw from source with Bun
  • Severity: blocks Bun runtime entirely (immediate crash on startup)
  • Frequency: 100% reproducible on every Bun invocation
  • Consequence: Bun cannot be used to run the gateway or any CLI command since v2026.3.22, despite README stating "Bun is optional for running TypeScript directly"

Additional information

Last known good: v2026.3.13-1. First known bad: v2026.3.22. Happy to open a PR if the approach looks good.

extent analysis

TL;DR

The most likely fix is to update the isDirectModuleNotFoundError function in openclaw.mjs to include a check for Bun's err.specifier property, in addition to the existing Node-specific checks.

Guidance

  • Review the suggested fix provided in the issue, which adds a check for err.specifier to the isDirectModuleNotFoundError function.
  • Verify that the fix works by running bun openclaw.mjs --version and bun openclaw.mjs --help after applying the patch.
  • Consider opening a PR with the suggested fix, as it has been verified to work on Bun 1.3.10 and does not affect Node behavior.
  • Ensure that the fix is properly tested on both Node and Bun to avoid introducing any regressions.

Example

The suggested fix is provided in the issue:

--- a/openclaw.mjs
+++ b/openclaw.mjs
@@ -56,10 +56,16 @@ const isDirectModuleNotFoundError = (err, specifier) => {
   }

   const expectedUrl = new URL(specifier, import.meta.url);
+  // Node sets err.url to the file URL of the missing module.
   if ("url" in err && err.url === expectedUrl.href) {
     return true;
   }

+  // Bun sets err.specifier to the original import specifier.
+  if ("specifier" in err && err.specifier === specifier) {
+    return true;
+  }
+
   const message = "message" in err && typeof err.message === "string" ? err.message : "";
   const expectedPath = fileURLToPath(expectedUrl);
   return (

Notes

The fix is specific to the isDirectModuleNotFoundError function and should not affect other parts of the codebase. However, thorough testing is still necessary to ensure that the fix does not introduce any regressions.

Recommendation

Apply the suggested workaround by adding the check for err.specifier to the isDirectModuleNotFoundError function, as it has been verified to work on Bun 1.3.10 and does not affect Node behavior.

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…

FAQ

Expected behavior

Prints version and exits, as it did on v2026.3.13-1 and earlier.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING