You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Experimental require of circular ESM graph stack overflow #52864
$ cat left.mjs
import {} from './right.mjs';
$ cat right.mjs
import {} from './left.mjs';
$ node left.mjs
# (nothing)
$ cat main.cjs
require('./left.mjs');
$ node --experimental-require-module main.cjs
node:fs:441
function readFileSync(path, options) {
^
RangeError: Maximum call stack size exceeded
at readFileSync (node:fs:441:22)
at getSourceSync (node:internal/modules/esm/load:85:14)
at defaultLoadSync (node:internal/modules/esm/load:201:32)
at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:363:24)
at new ModuleJobSync (node:internal/modules/esm/module_job:307:32)
at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:404:11)
at new ModuleJobSync (node:internal/modules/esm/module_job:307:32)
at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:404:11)
at new ModuleJobSync (node:internal/modules/esm/module_job:307:32)
at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:404:11)
Node.js v22.1.0
How often does it reproduce? Is there a required condition?
It reproduces consistently.
What is the expected behavior? Why is that the expected behavior?
Circular imports are well-defined in the specification and should work correctly.
Activity
laverdet commentedon May 6, 2024
@joyeecheung #51977 thanks!
GeoffreyBooth commentedon May 6, 2024
@nodejs/loaders
joyeecheung commentedon May 7, 2024
Thanks for reporting it, fix in #52868
module: cache synchronous module jobs before linking
test: add common.expectRequiredModule()
test: add common.expectRequiredModule()
module: cache synchronous module jobs before linking
test: add common.expectRequiredModule()
module: cache synchronous module jobs before linking
module: cache synchronous module jobs before linking