Fix #231076: Restore NODE_OPTIONS in Windows terminal#305671
Fix #231076: Restore NODE_OPTIONS in Windows terminal#305671diogocruzzz wants to merge 5 commits intomicrosoft:mainfrom
Conversation
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>
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @deepak1556Matched files:
|
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
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_MODULEasVSCODE_*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. |
|
Hello, @deepak1556, |
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>
|
I've addressed the review feedback in commit 275b5b2: Launchers now prefer existing VSCODE_* values instead of overwriting them Thanks for your time! |
|
@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! |
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.