-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node:child_process always inherits parent env variables #27343
Comments
nathanwhit
pushed a commit
that referenced
this issue
Jan 13, 2025
…nt environment (#27343) (#27340) 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. When `options.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 where `normalizeSpawnArguments` wasn't returning the `env` option if `options.env` was unset.
bartlomieju
pushed a commit
that referenced
this issue
Jan 16, 2025
…nt environment (#27343) (#27340) 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. When `options.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 where `normalizeSpawnArguments` wasn't returning the `env` option if `options.env` was unset.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version: Deno 2.1.3
Hi there 👋
I'm currently experiencing an issue where Deno's node:child_process polyfill is always passing the parent process's environment to spawned subprocesses even when the
env
option is provided. On Node it looks like the correct behaviour is for the parent environment to be inherited only whenenv
isn't specified, otherwise only the values fromenv
are passed to the environment.For example, the code:
When run on Node only outputs
'test=test\n'
but when run on Deno outputs the full parent environment in addition totest=test
.I've had a go at fixing this in #27340 😄
The text was updated successfully, but these errors were encountered: