fix(server): apps opened from T3 Code no longer inherit ELECTRON_RUN_AS_NODE #20206
main fromrefs/pull/20206/head·merged by juliusmarminge View on GitHubProblem#
The desktop app starts the server with ELECTRON_RUN_AS_NODE=1. The external launcher (open in browser, editor or file manager) spawned those apps with the server's full environment. A launched file manager passes the variable to everything started from it. On Linux, Open in file manager → open a terminal there → run any Electron app or Electron AppImage, and it starts as plain Node and exits:
$ ./my-electron-app.AppImage
/tmp/.mount_XXXX/my-electron-app: bad option: --no-sandbox
Workaround today: env -u ELECTRON_RUN_AS_NODE ./my-electron-app.AppImage.
Change#
launchAndUnref in apps/server/src/process/externalLauncher.ts is the single spawn point for browser, editor and file-manager launches. It now passes the host environment without ELECTRON_RUN_AS_NODE (extendEnv: false). Everything else in the environment is unchanged. The server's own Electron-as-Node launch, and spawns that set the variable explicitly (ACP bridge, Antigravity, cgroup wrapper), are not affected. VS Code does the same: its CLI deletes ELECTRON_RUN_AS_NODE before launching (src/vs/code/node/cli.ts), and sanitizeProcessEnvironment strips ELECTRON_*.
Scope and approval#
Refs #16456, a maintainer-triaged issue about the same leak. This comment describes the launcher path. #16679 fixes the provider-session half of the issue in mergeProviderInstanceEnvironment, and the terminal half is already fixed on main. This PR covers only the remaining launcher path and doesn't touch either of those files, so the two don't conflict. It's a one-function fix for an obvious defect.
Verification#
- Established on a Linux desktop install: the main process has no
ELECTRON_RUN_AS_NODE, the backend process has it, and a file manager opened from T3 Code (and a terminal started from it) inherits it. An Electron AppImage started there fails as shown above and works withenv -u ELECTRON_RUN_AS_NODE. - New test in
externalLauncher.test.tschecks that a browser and an editor launch on Linux get the host environment withoutELECTRON_RUN_AS_NODE, withPATH/DISPLAYkept. It fails onmainand passes here.vp test run apps/server/src/process/externalLauncher.test.ts: 55 passed, 2 skipped (Windows-only). vp lintonapps/server/src/process/is clean.- Not checked: a packaged build with this change, and the server typecheck. The local machine ran out of memory for
tsc, so I'm relying on CI for that.
Made with Claude Opus 5.5 in Claude Code, running in T3 Code.
🤖 Generated with Claude Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Approved at
9fb62dbMacroscope's review found this PR approvable — This is a small, self-contained server bug fix that sanitizes one Electron-specific environment variable from browser, editor, and file-manager launches while preserving the rest of the host environment. The accompanying test verifies the affected spawn commands and introduces no production behavior.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
eec82e93-f10f-4fa4-a116-237eb54d4212
📥 Commits
-
Reviewing files that changed from the base of the PR and between e3b35d1b2440b104f0bc2e357377c348121234dd and 9fb62dbb1426abfd6aedd85b42e0d5a3411bcef9.
📒 Files selected for processing: 2
-
apps/server/src/process/externalLauncher.test.tsapps/server/src/process/externalLauncher.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
📝 Walkthrough
-
External browser and file manager launches now exclude
ELECTRON_RUN_AS_NODEfrom the child environment. A Linux-only test checks the browser and VS Code launch environments.Changes: External launch environment
Layer / File(s) Summary Filter the child environment
apps/server/src/process/externalLauncher.ts,apps/server/src/process/externalLauncher.test.tslaunchAndUnrefremovesELECTRON_RUN_AS_NODEand passes the remaining environment withextendEnv: false. A Linux-only test checks that browser and VS Code launches receive onlyPATHandDISPLAY.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers:
juliusmarminge
Merge Risk: ⚪ Minimal · up to
9fb62-
No actionable merge-blocking issue is evident; merge after normal checks.
Security architecture risk: ⚪ Minimal · up to
9fb62-
The change removes one Electron execution-mode flag from external application launches without adding privileges, launch targets, or public interfaces. No material security risk introduced or worsened by this change was identified.
Retained concerns No architecture-level concerns identified.
Security review details
-
Security Blast Radius
- inferred — The affected scope is external applications launched through this helper and descendants that inherit their environment. The new options do not request additional credentials or elevated process privileges.
Trust Boundaries and Controls
- observed — This is a targeted execution-mode filter, not general environment or credential isolation. Other host variables remain available to launched applications, as they were before this PR; the change does not introduce that broader inheritance.
Resilience and Maintainability Implications
- observed — The environment copy precedes spawning without modifying shared state. Existing unref, scoped handling, and error mapping are preserved, so the patch introduces no new rollback or environment-restoration transition.
-
Pre-merge checks:
4-
Check name Status Explanation Title check The title clearly and concisely describes the primary fix: preventing launched applications from inheriting ELECTRON_RUN_AS_NODE. Description check The description includes complete Problem, Change, Scope and approval, and Verification sections. It provides reproduction details, issue references, test results, lint results, and limitations. Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
juliusmarminge merged this31be3e9
juliusmarminge closed this
Thanks for merging. 👍
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes