-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
ERR_INTERNAL_ASSERTION thrown when using --experimental-require-module and --import together #54577
Comments
$ touch repro.cjs
$ touch test.mjs
$ node --experimental-require-module --import=./test.mjs repro.cjs
(node:179265) ExperimentalWarning: Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/assert:14
throw new ERR_INTERNAL_ASSERTION(message);
^
Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
at assert (node:internal/assert:14:11)
at ModuleLoader.requireCommonJS (node:internal/modules/esm/translators:290:3)
at callTranslator (node:internal/modules/esm/loader:436:14)
at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:442:30)
at async ModuleJob._link (node:internal/modules/esm/module_job:106:19) {
code: 'ERR_INTERNAL_ASSERTION'
}
Node.js v22.7.0 |
The failed assertion is node/lib/internal/modules/esm/translators.js Line 243 in 3a71ccf
|
I think part of my WIP for synchronous hooks can fix this by handling the translations more correctly (i.e. properly distinguishing
require(esm) from CJS roots won't support the asynchronous module customization hooks, just like require(cjs) from CJS roots / |
Good point. I would probably have run into that next, if I hadn't gotten this error. For my case, I would also be using dynamic import from a CJS root, which should allow the async hooks if I understand correctly. |
It's basically this // main.cjs
import('./a.mjs'); // module.register() hooks are triggered when loading a.mjs
require('./b.mjs'); // module.register() hooks won't be triggered when loading `b.mjs`. Need to wait for the upcoming module.registerHooks() API. |
The synchronous CJS translator can handle entrypoints now, this can be hit when --import is used, so lift the bogus assertions and added tests. PR-URL: nodejs#54592 Fixes: nodejs#54577 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
The synchronous CJS translator can handle entrypoints now, this can be hit when --import is used, so lift the bogus assertions and added tests. PR-URL: #54592 Fixes: #54577 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
The synchronous CJS translator can handle entrypoints now, this can be hit when --import is used, so lift the bogus assertions and added tests. PR-URL: nodejs#54592 Fixes: nodejs#54577 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
The synchronous CJS translator can handle entrypoints now, this can be hit when --import is used, so lift the bogus assertions and added tests. PR-URL: nodejs#54592 Fixes: nodejs#54577 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Version
v22.7.0
Platform
Subsystem
No response
What steps will reproduce the bug?
With two files
test.mjs
andtest.cjs
(both files can be empty):How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
No error should be thrown, and
--experimental-require-module
and--import
can be used in combination. For example, to use module customization hooks when ECMAScript and CommonJS module types need to be mixed.What do you see instead?
This error is thrown:
Additional information
No response
The text was updated successfully, but these errors were encountered: