The issue involves deep ESM loader internals and cyclic dependencies.
The ESM module loader in Node.js 22.x crashes with a stack overflow when loading a large single-file bundled ESM package with cyclic re-exports. The fix likely requires understanding and modifying the ESM loader's handling of cyclic dependencies. The issue is reproducible but involves complex module loading internals.
Node version: v22.22.1
Linux x86_64 (Linux 5.15.0-100-generic)
ESM module loader / node:internal/modules/esm/utils compileSourceTextModule
Package: https://www.npmjs.com/package/openclaw
100% reproducible on every startup with Node.js 22.22.1.
Required conditions:
Expected: Node.js should successfully load the module and start the application.
This is the expected behavior because:
The ESM module loader goes into infinite recursion during loading and eventually crashes with:
RangeError: Maximum call stack size exceeded at compileSourceTextModule (node:internal/modules/esm/utils:346:16) at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:107:18) at #translate (node:internal/modules/esm/loader:546:20) at afterLoad (node:internal/modules/esm/loader:596:29) at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:601:12) at #createModuleJob (node:internal/modules/esm/loader:624:36) at #getJobFromResolveResult (node:internal/modules/esm/loader:343:41) at ModuleLoader.getModuleJobForImport (node:internal/m
Claim this issue to let others know you're working on it. You'll earn 35 points when you complete it!