GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — child_process: inherit a reassigned process.env by everett1992 · Pull Request #66883 · nodejs/node

Conversation

@everett1992

@everett1992 everett1992 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Since #65325 (first released in v26.11.0), spawning a child without options.env builds its environment from the OS environment block. If user code has reassigned process.env (process.env = { ...process.env, FOO: 'x' }), the child no longer sees the change, even though { env: process.env } still does. With --permission the old path is taken, which hides the bug. See #66882 for the repro and impact.

This keeps the fast path for the common case and only takes it while process.env is still the native env proxy. getEnvPairs() now takes the object and returns undefined unless env_proxy_ctor_template()->HasInstance() is true. That is the same check node_messaging.cc uses to recognize process.env when cloning it. The check is native because child_process can be loaded after process.env has been reassigned, so comparing against a reference captured in JS wouldn't work. Otherwise normalizeSpawnArguments() falls back to the copy path used before #65325. Spreading a plain object doesn't go through the interceptors, so that path is cheap there.

test/parallel/test-child-process-env-reassigned.js covers spawn, spawnSync, exec, execSync, execFile, execFileSync, fork, PATH lookup (non-Windows), parity with { env: process.env }, and assigning the original object back. It fails on v26.12.0 and passes on v26.10.0 and with this change.

Since this is a v26.11.0 regression, it would be good to land it before v26 goes LTS on 2026-10-28.

Fixes: #66882
Refs: #65325

I used Claude Code to write the patch, the test and this description. I reviewed the change and ran the new and existing child_process tests locally.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

felixonmars reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@everett1992
child_process: inherit a reassigned process.env
5a89d81
Since v26.11.0, spawning without options.env builds the child's
environment from the OS environment block. Code that replaces
process.env, e.g. process.env = { ...process.env, FOO: 'x' }, had its
changes silently dropped. The child_process docs give process.env as
the default for options.env, and { env: process.env } still saw the
replacement object, so the two disagreed.

Make getEnvPairs() take the object to read and return undefined unless
it is still the native env proxy. When it isn't, copy process.env as
before. A plain object is copied without going through the env
interceptors, so that path stays cheap.

Assisted-by: a closed-source coding agent
Signed-off-by: Caleb ツ Everett <[email protected]>
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. child_process Issues and PRs related to the child_process subsystem. needs-ci PRs that need a full CI run. labels Oct 20, 2026
@codecov

codecov Bot commented Oct 20, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.51%. Comparing base (967f0a7) to head (5a89d81).
⚠️ Report is 277 commits behind head on main.

Files with missing lines Patch % Lines
src/process_wrap.cc 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66883      +/-   ##
==========================================
+ Coverage   90.50%   90.51%   +0.01%     
==========================================
  Files         797      797              
  Lines      278268   278369     +101     
  Branches    53468    53482      +14     
==========================================
+ Hits       251838   251963     +125     
+ Misses      16813    16765      -48     
- Partials     9617     9641      +24     
Files with missing lines Coverage Δ
lib/child_process.js 91.50% <100.00%> (+0.10%) ⬆️
src/process_wrap.cc 75.65% <75.00%> (-0.02%) ⬇️

... and 36 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@everett1992

everett1992 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@nodejs/child_process @codebytere @@aduh95 @jasnell — this fixes #66882, a regression from #65325 where a reassigned process.env is no longer inherited by children. It keeps the fast path for the common case.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cjihrig
cjihrig approved these changes Oct 21, 2026
View reviewed changes
addaleax
addaleax approved these changes Oct 30, 2026
View reviewed changes
@addaleax addaleax added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Oct 30, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 30, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78745/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78765/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@everett1992

everett1992 commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

CI is green (node-test-pull-request/78765) and this has two approvals. Could someone add commit-queue? @addaleax

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aduh95 aduh95 added the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 10, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 2aef805 into nodejs:main Nov 10, 2026
83 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Landed in 2aef805

everett1992 reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 10, 2026
aduh95 pushed a commit that referenced this pull request Nov 11, 2026
@everett1992 @aduh95
child_process: inherit a reassigned process.env
2f89ed5
Since v26.11.0, spawning without options.env builds the child's
environment from the OS environment block. Code that replaces
process.env, e.g. process.env = { ...process.env, FOO: 'x' }, had its
changes silently dropped. The child_process docs give process.env as
the default for options.env, and { env: process.env } still saw the
replacement object, so the two disagreed.

Make getEnvPairs() take the object to read and return undefined unless
it is still the native env proxy. When it isn't, copy process.env as
before. A plain object is copied without going through the env
interceptors, so that path stays cheap.

Assisted-by: a closed-source coding agent
Signed-off-by: Caleb ツ Everett <[email protected]>
PR-URL: #66883
Fixes: #66882
Refs: #65325
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 11, 2026
2026-11-12, Version 27.0.0-alpha.0.1.0 (Alpha) #67415
Merged
aduh95 pushed a commit that referenced this pull request Nov 12, 2026
@everett1992 @aduh95
child_process: inherit a reassigned process.env
3eb5b6b
Since v26.11.0, spawning without options.env builds the child's
environment from the OS environment block. Code that replaces
process.env, e.g. process.env = { ...process.env, FOO: 'x' }, had its
changes silently dropped. The child_process docs give process.env as
the default for options.env, and { env: process.env } still saw the
replacement object, so the two disagreed.

Make getEnvPairs() take the object to read and return undefined unless
it is still the native env proxy. When it isn't, copy process.env as
before. A plain object is copied without going through the env
interceptors, so that path stays cheap.

Assisted-by: a closed-source coding agent
Signed-off-by: Caleb ツ Everett <[email protected]>
PR-URL: #66883
Fixes: #66882
Refs: #65325
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
aduh95 pushed a commit that referenced this pull request Nov 12, 2026
@everett1992 @aduh95
child_process: inherit a reassigned process.env
b0c030c
Since v26.11.0, spawning without options.env builds the child's
environment from the OS environment block. Code that replaces
process.env, e.g. process.env = { ...process.env, FOO: 'x' }, had its
changes silently dropped. The child_process docs give process.env as
the default for options.env, and { env: process.env } still saw the
replacement object, so the two disagreed.

Make getEnvPairs() take the object to read and return undefined unless
it is still the native env proxy. When it isn't, copy process.env as
before. A plain object is copied without going through the env
interceptors, so that path stays cheap.

Assisted-by: a closed-source coding agent
Signed-off-by: Caleb ツ Everett <[email protected]>
PR-URL: #66883
Fixes: #66882
Refs: #65325
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@felixonmars felixonmars mentioned this pull request Nov 14, 2026
updpatch: nodejs 26.13.1-1 felixonmars/archriscv-packages#6519
Merged
felixonmars added a commit to felixonmars/archriscv-packages that referenced this pull request Nov 14, 2026
@felixonmars
updpatch: nodejs 26.13.1-1
9551feb
Extend Arch's prepare() instead of redefining it, preserving the OpenSSL
4.x test and child-process environment backports. The duplicate function
silently discarded both, leaving test-x509-escaping expecting
'good.example.com' where OpenSSL 4.1 returns undefined.

https://gitlab.archlinux.org/archlinux/packaging/packages/nodejs/-/blob/26.13.1-1/PKGBUILD
nodejs/node#66775
nodejs/node#66883
https://archriscv.felixc.at/.status/logs/nodejs/nodejs-26.13.1-1.log
@github-actions github-actions Bot mentioned this pull request Nov 20, 2026
2026-11-30, Version 26.14.0 'Lithium' (LTS) #67664
Open
gabylb pushed a commit to gabylb/node that referenced this pull request Nov 27, 2026
@everett1992 @gabylb
child_process: inherit a reassigned process.env
936b14e
Since v26.11.0, spawning without options.env builds the child's
environment from the OS environment block. Code that replaces
process.env, e.g. process.env = { ...process.env, FOO: 'x' }, had its
changes silently dropped. The child_process docs give process.env as
the default for options.env, and { env: process.env } still saw the
replacement object, so the two disagreed.

Make getEnvPairs() take the object to read and return undefined unless
it is still the native env proxy. When it isn't, copy process.env as
before. A plain object is copied without going through the env
interceptors, so that path stays cheap.

Assisted-by: a closed-source coding agent
Signed-off-by: Caleb ツ Everett <[email protected]>
PR-URL: nodejs#66883
Fixes: nodejs#66882
Refs: nodejs#65325
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@addaleax addaleax addaleax approved these changes
@cjihrig cjihrig cjihrig approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. child_process Issues and PRs related to the child_process subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

child_process: default env ignores a reassigned process.env since v26.11.0

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@everett1992 @nodejs-github-bot @addaleax @cjihrig @aduh95
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.