Title: require(esm) inside a module.register() hook module fails with ERR_INTERNAL_ASSERTION in 26.12.0 · Issue #66767 · nodejs/node · GitHub
Open Graph Title: require(esm) inside a module.register() hook module fails with ERR_INTERNAL_ASSERTION in 26.12.0 · Issue #66767 · nodejs/node
X Title: require(esm) inside a module.register() hook module fails with ERR_INTERNAL_ASSERTION in 26.12.0 · Issue #66767 · nodejs/node
Description: Version v26.12.0 (works on v26.11.1 and v26.10.0) Platform Linux x64 Subsystem esm, module What steps will reproduce the bug? // repro.mjs import { mkdtempSync, writeFileSync } from 'node:fs' import { register } from 'node:module' import...
Open Graph Description: Version v26.12.0 (works on v26.11.1 and v26.10.0) Platform Linux x64 Subsystem esm, module What steps will reproduce the bug? // repro.mjs import { mkdtempSync, writeFileSync } from 'node:fs' impor...
X Description: Version v26.12.0 (works on v26.11.1 and v26.10.0) Platform Linux x64 Subsystem esm, module What steps will reproduce the bug? // repro.mjs import { mkdtempSync, writeFileSync } from 'node:fs...
Opengraph URL: https://github.com/nodejs/node/issues/66767
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"require(esm) inside a module.register() hook module fails with ERR_INTERNAL_ASSERTION in 26.12.0","articleBody":"### Version\n\nv26.12.0 (works on v26.11.1 and v26.10.0)\n\n### Platform\n\n```text\nLinux x64\n```\n\n### Subsystem\n\nesm, module\n\n### What steps will reproduce the bug?\n\n```js\n// repro.mjs\nimport { mkdtempSync, writeFileSync } from 'node:fs'\nimport { register } from 'node:module'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\n\n// Any ES module with at least one import (one without imports works)\nconst esm = join(mkdtempSync(join(tmpdir(), 'require-esm-')), 'esm.mjs')\nwriteFileSync(esm, \"import 'node:fs'\\n\")\n\n// The hook module defines no hooks: loading it in the hooks thread is enough\nconst hooks = `\nimport { createRequire } from 'node:module'\ncreateRequire(${JSON.stringify(esm)})(${JSON.stringify(esm)})\n`\n\nregister('data:text/javascript,' + encodeURIComponent(hooks))\nconsole.log('ok')\n```\n\n```sh\nnode repro.mjs\n```\n\n\n\n### How often does it reproduce? Is there a required condition?\n\nAlways. Required conditions:\n\n- The `require()` happens while loading a `module.register()` hook module (the hooks thread).\n- The required ES module has at least one import. With `export {}` instead, it prints `ok`.\n\nNo hooks need to be exported: the hook module defines none.\n\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`ok` is printed, as on v26.11.1 and v26.10.0 (which only print the `module.register()`\ndeprecation warning).\n\n\n### What do you see instead?\n\n\n```\nError [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.\nPlease open an issue with this stack trace at https://github.com/nodejs/node/issues\n\n at assert (node:internal/assert:11:11)\n at ModuleJobSync.syncLink (node:internal/modules/esm/module_job:330:9)\n at ModuleJobSync.link (node:internal/modules/esm/module_job:626:17)\n at new ModuleJobSync (node:internal/modules/esm/module_job:616:26)\n at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:352:11)\n at loadESMFromCJS (node:internal/modules/cjs/loader:1786:24)\n at Module._compile (node:internal/modules/cjs/loader:1950:5)\n at Object..js (node:internal/modules/cjs/loader:2108:10)\n at Module.load (node:internal/modules/cjs/loader:1690:32)\n at Module._load (node:internal/modules/cjs/loader:1480:12) {\n code: 'ERR_INTERNAL_ASSERTION'\n}\n```\n\nThe failing assertion is `assert(!isPromise(job))` in `ModuleJobSync.syncLink()`: inside the\nhooks thread, `getOrCreateModuleJob()` returns a promise for the required module's dependency\nwhile the module is being linked synchronously for `require()`.\n\n\n### Additional information\n\nBisected between releases only: v26.11.1 works, v26.12.0 fails. v26.12.0 includes\n\"module: synchronously load most ES modules\" (#62530), which changed this code path; that PR is\nthe likely cause but the exact commit was not bisected.\n","author":{"url":"https://github.com/ivan-tymoshenko","@type":"Person","name":"ivan-tymoshenko"},"datePublished":"2026-10-15T15:15:51Z","url":"https://github.com/nodejs/node/issues/66767"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:16a2e7a1-5ad0-6748-e721-a7cdbc060eaa |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9096:1F5F5F:8409D3:AF712F:6AED27F7 |
| html-safe-nonce | c99c1d12d3c2cadb7539ec9e2f9d41fefad7d3b59b0a08108093df75e767e38f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDk2OjFGNUY1Rjo4NDA5RDM6QUY3MTJGOjZBRUQyN0Y3IiwidmlzaXRvcl9pZCI6IjU2NzgxNDY1NTE4MDQ2Njc4OTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8acc6d027656f333be84b27752a043395526dbb69d96bf7f0ca2d233f29049be |
| hovercard-subject-tag | issue:5868823886 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/66767/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ca53c7409600eea8c92393c15f259620090392b144e8f894a449d292f153040a/nodejs/node/issues/66767 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ca53c7409600eea8c92393c15f259620090392b144e8f894a449d292f153040a/nodejs/node/issues/66767 |
| og:image:alt | Version v26.12.0 (works on v26.11.1 and v26.10.0) Platform Linux x64 Subsystem esm, module What steps will reproduce the bug? // repro.mjs import { mkdtempSync, writeFileSync } from 'node:fs' impor... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ivan-tymoshenko |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9d95365dda0576efe9b71f45807595e396bd0ca9286fba5367a05048e6ddf8f2 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 98b41fa4b5635ceb45a4c54320fced73817ff290 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width