Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node --experimental-require-module issue with dependency between pkg-types and mlly #191

Closed
sxzz opened this issue Aug 24, 2024 · 3 comments

Comments

@sxzz
Copy link
Member

sxzz commented Aug 24, 2024

Environment

node: v20.17.0

Reproduction

// test.js
import 'pkg-types'

And run node --experimental-require-module -e 'require("./test.js")'

Describe the bug

pkg-types and mlly are circular dependencies, causing a stack overflow when the --experimental-require-module option is enabled.

Additional context

No response

Logs

❯ node --experimental-require-module -e 'require("./test.js")'
node:fs:570
function openSync(path, flags, mode) {
                 ^

RangeError: Maximum call stack size exceeded
    at Object.openSync (node:fs:570:18)
    at readFileSync (node:fs:452:35)
    at getSourceSync (node:internal/modules/esm/load:85:14)
    at defaultLoadSync (node:internal/modules/esm/load:201:32)
    at ModuleLoader.getModuleWrapForRequire (node:internal/modules/esm/loader:362:24)
    at new ModuleJobSync (node:internal/modules/esm/module_job:276:32)
    at ModuleLoader.getModuleWrapForRequire (node:internal/modules/esm/loader:403:11)
    at new ModuleJobSync (node:internal/modules/esm/module_job:276:32)
    at ModuleLoader.getModuleWrapForRequire (node:internal/modules/esm/loader:403:11)
    at new ModuleJobSync (node:internal/modules/esm/module_job:276:32)

Node.js v20.17.0
@sxzz sxzz added the bug Something isn't working label Aug 24, 2024
@pi0
Copy link
Member

pi0 commented Aug 24, 2024

Thanks for report. I'm aware of this but both ESM and CJS loaders are supposed to support circular dependencies. In fact, the core of Node.js has many of them!

It seems an implementation issue to me with node --experimental-require-module flag..

@pi0 pi0 removed the bug Something isn't working label Aug 24, 2024
@pi0 pi0 changed the title Circular dependency between pkg-types and mlly node --experimental-require-module issue with dependency between pkg-types and mlly Aug 24, 2024
@pi0
Copy link
Member

pi0 commented Aug 24, 2024

We can fix it somehow (and as a bonus gain little of loader perf): unjs/mlly#274

it is still a node.js bug..

@sxzz
Copy link
Member Author

sxzz commented Sep 25, 2024

Fixed in latest v22

@sxzz sxzz closed this as completed Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants