Skip to content

Fix #231076: Restore NODE_OPTIONS in Windows terminal#305671

Open
diogocruzzz wants to merge 5 commits intomicrosoft:mainfrom
diogocruzzz:fix-231076-node-options
Open

Fix #231076: Restore NODE_OPTIONS in Windows terminal#305671
diogocruzzz wants to merge 5 commits intomicrosoft:mainfrom
diogocruzzz:fix-231076-node-options

Conversation

@diogocruzzz
Copy link
Copy Markdown

VS Code on Windows did not propagate NODE_OPTIONS to integrated

terminals when launched from an external shell.

Electron strips most NODE_OPTIONS from the app process. This fix

preserves the value as VSCODE_NODE_OPTIONS before Electron startup

in launcher scripts and restores it when creating terminal env.

Changes included:

  • preserve NODE_OPTIONS and NODE_REPL_EXTERNAL_MODULE in launchers

  • restore variables for Windows in terminal environment logic

  • add test coverage for NODE_OPTIONS restoration behavior

Root cause:
Electron strips most NODE_OPTIONS in the app process, so Windows integrated terminals were not inheriting the expected value.
Fix:
Preserve NODE_OPTIONS and NODE_REPL_EXTERNAL_MODULE as VSCODE-prefixed values before startup and restore them in terminal environment creation.
Validation:
Manual validation in integrated terminal with heap limit check.
Focused terminal environment tests passing.

VS Code on Windows did not propagate NODE_OPTIONS to integrated

terminals when launched from an external shell.

Electron strips most NODE_OPTIONS from the app process. This fix

preserves the value as VSCODE_NODE_OPTIONS before Electron startup

in launcher scripts and restores it when creating terminal env.

Changes included:

- preserve NODE_OPTIONS and NODE_REPL_EXTERNAL_MODULE in launchers

- restore variables for Windows in terminal environment logic

- add test coverage for NODE_OPTIONS restoration behavior

Signed-off-by: Diogo Cruz <diogo.noronha.cruz@tecnico.ulisboa.pt>
Copilot AI review requested due to automatic review settings March 27, 2026 14:40
@vs-code-engineering
Copy link
Copy Markdown
Contributor

vs-code-engineering Bot commented Mar 27, 2026

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@deepak1556

Matched files:

  • src/vs/code/electron-main/main.ts

@diogocruzzz
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores NODE_OPTIONS (and NODE_REPL_EXTERNAL_MODULE) propagation into integrated terminals on Windows (and macOS) when VS Code is launched from an external shell/CLI, working around Electron’s sanitization of NODE_OPTIONS in the app process.

Changes:

  • Preserve NODE_OPTIONS/NODE_REPL_EXTERNAL_MODULE as VSCODE_* variables in dev launcher scripts.
  • Restore these variables during terminal environment creation on Windows (in addition to existing macOS behavior).
  • Add a regression test covering the restore behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/vs/workbench/contrib/terminal/common/terminalEnvironment.ts Restores NODE_OPTIONS/NODE_REPL_EXTERNAL_MODULE from VSCODE_* on Windows/macOS before env sanitization.
src/vs/workbench/contrib/terminal/test/common/terminalEnvironment.test.ts Adds a test for VSCODE_*NODE_* restoration behavior.
src/vs/code/electron-main/main.ts Attempts to preserve NODE_OPTIONS/NODE_REPL_EXTERNAL_MODULE into instanceEnvironment for later terminal restore.
scripts/code.sh Copies NODE_* into VSCODE_* when launching the dev build.
scripts/code.bat Copies NODE_* into VSCODE_* when launching the dev build on Windows.

Comment thread src/vs/code/electron-main/main.ts Outdated
Comment thread src/vs/workbench/contrib/terminal/test/common/terminalEnvironment.test.ts Outdated
Comment thread scripts/code.sh Outdated
Comment thread scripts/code.bat Outdated
@diogocruzzz
Copy link
Copy Markdown
Author

Hello, @deepak1556,
Just following up on this PR. Let me know if you have any feedback or if anything is needed from my side.
Thanks!

Preserve NODE_OPTIONS and NODE_REPL_EXTERNAL_MODULE as VSCODE_* variables in launch scripts. Prefer existing VSCODE_* values during terminal environment creation. Add regression test to ensure restore behavior works correctly on macOS and Windows.

Signed-off-by: Diogo Cruz <diogo.noronha.cruz@tecnico.ulisboa.pt>
@diogocruzzz
Copy link
Copy Markdown
Author

I've addressed the review feedback in commit 275b5b2:

Launchers now prefer existing VSCODE_* values instead of overwriting them
Added regression test to verify the restore behavior works correctly with conflicting NODE_* and VSCODE_* inputs
Ready for re-review.

Thanks for your time!

@diogocruzzz
Copy link
Copy Markdown
Author

@bpasero @deepak1556 Hello again! Just a gentle ping on this PR. I've addressed the previous review feedback and merged the latest main.

Could a maintainer please approve the workflows so the CI checks can run? Let me know if you need any further changes from my side. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants