worker: parse NODE_OPTIONS when env option is not provided#62306
Open
semimikoh wants to merge 2 commits intonodejs:mainfrom
Open
worker: parse NODE_OPTIONS when env option is not provided#62306semimikoh wants to merge 2 commits intonodejs:mainfrom
semimikoh wants to merge 2 commits intonodejs:mainfrom
Conversation
This was referenced Mar 18, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #62306 +/- ##
========================================
Coverage 89.66% 89.66%
========================================
Files 676 676
Lines 206575 206693 +118
Branches 39555 39583 +28
========================================
+ Hits 185225 185339 +114
+ Misses 13501 13495 -6
- Partials 7849 7859 +10
🚀 New features to boost your workflow:
|
Member
|
Thank you, could you add a test for this? |
Contributor
Author
|
Added a test in 9f345a9. It verifies that NODE_OPTIONS set at runtime are picked up by a worker when the env option is not provided. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When env option is not explicitly provided to new Worker(),
runtime changes to process.env.NODE_OPTIONS (e.g. adding --import)
are not picked up by the worker thread.
This happens because in node_worker.cc, the NODE_OPTIONS parsing
block is gated behind args[1]->IsObject() || args[2]->IsArray().
When env is not provided, args[1] is null (cloned from
process.env), so the condition is false and NODE_OPTIONS parsing
is skipped entirely.
This fix adds args[1]->IsNull() to the condition so that
NODE_OPTIONS is also parsed when the env is inherited (cloned)
from the parent process.
Fixes: #62301