fix(node): Prevent node:child_process from always inheriting the parent environment (#27343) #27340
+69
−0
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.
Fixes #27343
Currently the node:child_process polyfill is always passing the full parent environment to all spawned subprocesses. In the case where
options.env
is provided those keys are overridden but the rest of the parent environment is still passed through.On Node the behaviour is for child processes to only inherit the parent environment when
options.env
isn't specified. Whenoptions.env
is specified the child process inherits only those keys.This PR updates the internal node child_process polyfill so that the
clearEnv
argument is set to true when spawning the subprocess to prevent the parent environment always being inherited by default. It also fixes an issue wherenormalizeSpawnArguments
wasn't returning theenv
option ifoptions.env
was unset.