Repository navigation
ERR_INTERNAL_ASSERTION with require(esm) #55500
Copy link
Copy link
Closed
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.loadersIssues and PRs related to ES module loaders.Issues and PRs related to ES module loaders.
Description
Activity
The relevant code is in
packages/babel-core/lib/config/files/module-types.js.What is going on is that:
- in
loadCodeDefault, we go in theauto .jsbranch - it calls
loadCjsDefault, whichrequiresplugin.js - that require call throws due to TLA
- In the
catchinsideloadCodeDefault,async ??= yield* isAsync()istrueto we suppress the error - It falls through, and calls
loadMjsFromPathin theauto .mjsbranch loadMjsFromPathcallsimport_(url), which callsimport(url)
However, a minimal reproduction of
try/catcharoundrequire()falling back toimport()does not trigger the assertion.- in
Minimal reproduction:
try { require("./file-with-tla.mjs"); } catch { import("./file-with-tla.mjs").then(console.log, console.error); }
- addedesmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.loadersIssues and PRs related to ES module loaders.Issues and PRs related to ES module loaders.confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.
on Oct 23, 2024 // tla.js await new Promise(resolve => resolve());
try { require("./tla.js"); } catch { import("./tla.js"); }
Failing assertion:
node/lib/internal/modules/esm/module_job.js
Line 358 in 7b5d660
assert(status === kEvaluated, Thanks for reporting it, fix in #55502
Reacted by Nicolò Ribaudo and Ernesto Pérez Mateo- added a commit that references this issue
on Oct 28, 2024 - added a commit that references this issue
on Nov 1, 2024 - added a commit that references this issue
on Nov 23, 2024 - added a commit that references this issue
on Nov 27, 2024 - added a commit that references this issue
on Feb 11, 2025 - added a commit that references this issue
on Aug 27, 2026
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.loadersIssues and PRs related to ES module loaders.Issues and PRs related to ES module loaders.
Version
23.0.0
Platform
Subsystem
No response
What steps will reproduce the bug?
EDIT: See in #55500 (comment) for a minimal reproduction
yarn installmake use-esm(cd ./packages/babel-core/test/fixtures/async/plugin-mjs-tla-native; node ../../babel-compile-async.mjs ./input.js)How often does it reproduce? Is there a required condition?
I don't have a minimal reproduction
What is the expected behavior? Why is that the expected behavior?
To not tell me to open a bug report :P
What do you see instead?
Additional information
I don't think I'm using Node.js internals.
cc @joyeecheung