From 3e7ea8f55d2169783bfaa9cfcc915589bb0716e7 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Fri, 16 Jan 2026 19:42:59 -0800 Subject: [PATCH] fix(desktop): filter subprocess env in persistent terminal sessions The subprocess (pty-subprocess.js) was spawned with raw process.env, which includes NODE_ENV and other vars that should be filtered. Now uses the same filtered processEnv for both subprocess and PTY shell. --- apps/desktop/src/main/terminal-host/session.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/desktop/src/main/terminal-host/session.ts b/apps/desktop/src/main/terminal-host/session.ts index a8020192a1f..fd0bf30143f 100644 --- a/apps/desktop/src/main/terminal-host/session.ts +++ b/apps/desktop/src/main/terminal-host/session.ts @@ -180,14 +180,11 @@ export class Session { const shellArgs = this.getShellArgs(this.shell); const subprocessPath = path.join(__dirname, "pty-subprocess.js"); - // Use electron as node to run the subprocess + // Spawn subprocess with filtered env to prevent leaking NODE_ENV etc. const electronPath = process.execPath; this.subprocess = spawn(electronPath, [subprocessPath], { - stdio: ["pipe", "pipe", "inherit"], // pipe stdin/stdout, inherit stderr - env: { - ...process.env, - ELECTRON_RUN_AS_NODE: "1", - }, + stdio: ["pipe", "pipe", "inherit"], + env: { ...processEnv, ELECTRON_RUN_AS_NODE: "1" }, }); // Read framed messages from subprocess stdout