fix(vscode): strip Electron env vars in dev launch script (#8906)

* fix(vscode): strip Electron env vars in dev launch script

When bun run extension is invoked from a VS Code task (e.g. the Agent
Manager run button), ELECTRON_* and VSCODE_* env vars leak into the
spawned process, causing VS Code to reuse the existing instance instead
of opening a new window. Strip these vars before spawning.

* fix(vscode): also strip Electron env vars in blocking launch path
This commit is contained in:
Marius
2026-04-14 14:44:28 +02:00
committed by GitHub
parent 71b6dc903d
commit 4888fe2046
+9 -2
View File
@@ -303,6 +303,13 @@ async function launch() {
args.push("--wait")
}
// Strip Electron/VS Code env vars so the spawned instance doesn't attach
// to the current Electron process (e.g. when launched from a VS Code task).
const env = { ...process.env }
for (const key of Object.keys(env)) {
if (key.startsWith("ELECTRON_") || key.startsWith("VSCODE_")) delete env[key]
}
console.log(`[launch] Starting VS Code (${mode} mode)`)
console.log(`[launch] Executable: ${app}`)
console.log(`[launch] Workspace: ${workspace}`)
@@ -311,7 +318,7 @@ async function launch() {
if (blocking) {
const result = Bun.spawnSync([app, ...args], {
cwd: workspace,
env: process.env,
env,
stdio: ["ignore", "inherit", "inherit"],
})
console.log(`[launch] VS Code exited (code ${result.exitCode})`)
@@ -321,7 +328,7 @@ async function launch() {
const child = spawn(app, args, {
cwd: workspace,
detached: !win,
env: process.env,
env,
stdio: "ignore",
...(win ? { shell: true } : {}),
})