Skip to content

Conversation

@abdulfarid-dev
Copy link

This patch prevents Node.js from attempting to load V8 tool scripts under
internal/deps/v8/tools/ as builtin modules.

These files are part of V8’s internal tooling and are not valid Node.js
builtins. When required or imported with --expose-internals, the loader
attempts to treat them as builtin CJS modules, which results in either:

  • SyntaxError: Unexpected token 'export'
    (because the V8 tool scripts contain ESM syntax), or
  • AssertionError in BuiltinLoader::LookupAndCompileFunction
    (data->IsValue()), aborting the process.

This change adds a guard in loadBuiltinModule() to skip any module whose
path starts with internal/deps/v8/tools/, and also adds a defensive check
to avoid calling compileForPublicLoader() when no builtin module entry
exists.

This aligns the behavior with expectations and avoids a crash when users
attempt to load these paths with --expose-internals.

Fixes: #60865

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run. labels Nov 29, 2025
Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's the right place to pass that, we don't want to impact the happy path. Also, it makes no sense to add those to the list of builtin modules in src/node_builtins.cc only to filter them out on the JS side.

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

Labels

module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Importing internal/deps/v8/tools/* crashes

3 participants