Skip to content

module: forward execArgv to ESM loader hook worker - #65543

Open
santusht06 wants to merge 1 commit into
nodejs:mainfrom
santusht06:fix-worker-loader-conditions
Open

module: forward execArgv to ESM loader hook worker#65543
santusht06 wants to merge 1 commit into
nodejs:mainfrom
santusht06:fix-worker-loader-conditions

Conversation

@santusht06

Copy link
Copy Markdown

When spawning the internal worker thread for asynchronous loader hooks in AsyncLoaderHookWorker (lib/internal/modules/esm/hooks.js), process.execArgv was not passed to the InternalWorker constructor options.

As a result, custom CLI flags such as --conditions <tag> set when creating a Worker thread were omitted from the loader hook worker thread's options.

Changes

  • Passed execArgv: process.execArgv to new InternalWorker('internal/modules/esm/worker', ...) in lib/internal/modules/esm/hooks.js.
  • Added test/es-module/test-esm-loader-worker-conditions.mjs to verify that custom conditions passed to a Worker are properly forwarded and accessible to the ESM loader hook thread.

Fixes: #50885

When spawning the internal worker thread for asynchronous loader hooks
in AsyncLoaderHookWorker, process.execArgv was not passed to the
InternalWorker constructor options.

As a result, custom CLI flags such as `--conditions <tag>` set when
creating a Worker thread were omitted from the loader hook worker
thread's environment.

This commit forwards `process.execArgv` to the `InternalWorker` instance
so that loader hooks registered within worker threads receive custom
conditions and options.

Fixes: nodejs#50885
Signed-off-by: Santusht kotai <115890693+santusht06@users.noreply.github.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. labels Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--conditions xxx cannot pass into worker_thread

2 participants