Skip to content

Error [ERR_INTERNAL_ASSERTION]: Unexpected module status 0. Cannot require() ES Module ... because it is not yet fully loaded. #62130

Closed as not planned

Description

@nicolo-ribaudo

Version

25.8.0

Platform

Linux nic-desktop 6.17.0-14-generic #14-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan  9 17:01:16 UTC 2026 x86_64 GNU/Linux

Subsystem

require(esm)

What steps will reproduce the bug?

  1. Clone https://github.com/nicolo-ribaudo/babel-polyfills/tree/nodejs-bug
  2. Run yarn && yarn build
  3. Run yarn jest es-shims

Note that this is not using Jest's vm-based ESM support. It's using jest-light-runner to run directly in native Node.js ESM.

How often does it reproduce? Is there a required condition?

Consistently. Note that if I run only one test (yarn jest es-shims -t "tepmlate tag") it does not fail.

What is the expected behavior? Why is that the expected behavior?

That it does not tell me to submit a bug report :P

What do you see instead?

    Error [ERR_INTERNAL_ASSERTION]: [BABEL]: Unexpected module status 0. Cannot require() ES Module /home/nic/Documents/dev/github.com/babel/babel-polyfills/packages/babel-plugin-polyfill-es-shims/lib/index.js because it is not yet fully loaded.
    This may be caused by a race condition if the module is simultaneously dynamically import()-ed via Promise.all().
    Try await-ing the import() sequentially in a loop instead.
     (From /home/nic/Documents/dev/github.com/babel/babel-polyfills/packages/babel-plugin-polyfill-es-shims/test/node_modules/@@/babel-plugin-polyfill-es-shims.js in non-loader-hook thread)
    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
     (While processing: /home/nic/Documents/dev/github.com/babel/babel-polyfills/packages/babel-plugin-polyfill-es-shims/test/node_modules/@@/babel-plugin-polyfill-es-shims.js)
        at assert.fail (node:internal/assert:17:9)
        at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:358:16)
        at loadESMFromCJS (node:internal/modules/cjs/loader:1620:24)
        at Module._compile (node:internal/modules/cjs/loader:1785:5)
        at Object..js (node:internal/modules/cjs/loader:1934:10)
        at Module.load (node:internal/modules/cjs/loader:1524:32)
        at Module._load (node:internal/modules/cjs/loader:1326:12)
        at TracingChannel.traceSync (node:diagnostics_channel:328:14)
        at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
        at Module.require (node:internal/modules/cjs/loader:1547:12)
        at require (node:internal/modules/helpers:152:16)
        at Object.<anonymous> (/home/nic/Documents/dev/github.com/babel/babel-polyfills/packages/babel-plugin-polyfill-es-shims/test/node_modules/@@/babel-plugin-polyfill-es-shims.js:1:18)
        at Module._compile (node:internal/modules/cjs/loader:1803:14)
        at Object..js (node:internal/modules/cjs/loader:1934:10)
        at Module.load (node:internal/modules/cjs/loader:1524:32)
        at Module._load (node:internal/modules/cjs/loader:1326:12)
        at TracingChannel.traceSync (node:diagnostics_channel:328:14)
        at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
        at Module.require (node:internal/modules/cjs/loader:1547:12)
        at require (node:internal/modules/helpers:152:16)

Additional information

No response

Activity

  1. nicolo-ribaudo commented on Mar 6, 2026

    @nicolo-ribaudo
    ContributorAuthor

    The problem is caused by this import: https://github.com/nicolo-ribaudo/babel-polyfills/blob/16a066b5667e818830907da5097e51ac4593d6ab/packages/babel-plugin-polyfill-es-shims/src/index.ts#L7

    It's importing from this file: https://github.com/nicolo-ribaudo/babel-polyfills/blob/nodejs-bug/packages/babel-plugin-polyfill-es-shims/data/polyfills.js

    Which is an ESM file (because of package.json#type) but contains CommonJS.

    If I instead import directly import polyfills from "../data/polyfills.json" with { type: "json" };, then it works.

    I would expect to see an actual error such as "that module does not have a default export" or "module is not defined in ESM".

  2. added
    esm
    on Mar 6, 2026
  3. github-actions commented on Jul 20, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 90 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  4. added
    stale
    on Jul 20, 2026
  5. nicolo-ribaudo commented on Jul 20, 2026

    @nicolo-ribaudo
    ContributorAuthor

    Still happening in 26.5.0, but now instead of ERR_INTERNAL_ASSERTION it's ERR_REQUIRE_ESM_RACE_CONDITION. Does that mean that the error is expected behavior?

  6. removed
    stale
    on Jul 21, 2026
  7. github-actions commented on Oct 20, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 90 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  8. added
    stale
    on Oct 20, 2026
  9. github-actions commented on Nov 20, 2026

    @github-actions
    Contributor

    This issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 120 days).
    If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    esmstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions