TypeScript
fix(shell): avoid interactive job control in environment probes (#11275)
Louis Deconinck7f63b1027510
diff --git a/packages/shared/src/shell.test.ts b/packages/shared/src/shell.test.tsindex 38c305ac116..8343a58b8ae 100644--- a/packages/shared/src/shell.test.ts+++ b/packages/shared/src/shell.test.ts@@ -87,7 +87,12 @@ describe("readEnvironmentFromLoginShell probe", () => {expect(args?.[1]).toContain("printenv PATH || true");expect(args?.[1]).toContain("__T3CODE_ENV_PATH_START__");expect(args?.[1]).toContain("__T3CODE_ENV_PATH_END__");- expect(options).toEqual({ encoding: "utf8", timeout: 5000 });+ expect(options).toEqual({+ encoding: "utf8",+ timeout: 5000,+ detached: true,+ stdio: ["ignore", "pipe", "ignore"],+ });});});diff --git a/packages/shared/src/shell.ts b/packages/shared/src/shell.tsindex 1e0a1fecf2f..983ba0598eb 100644--- a/packages/shared/src/shell.ts+++ b/packages/shared/src/shell.ts@@ -20,7 +20,12 @@ const WINDOWS_SHELL_CANDIDATES = ["pwsh.exe", "powershell.exe"] as const;type ExecFileSyncLike = (file: string,args: ReadonlyArray<string>,- options: { encoding: "utf8"; timeout: number },+ options: {+ encoding: "utf8";+ timeout: number;+ detached?: true;+ stdio?: ["ignore", "pipe", "ignore"];+ },) => string;function canExecuteFile(filePath: string): boolean {@@ -268,9 +273,13 @@ export const readEnvironmentFromLoginShell: ShellEnvironmentReader = (return {};}+ // Interactive startup loads PATH entries; detaching prevents job control on an+ // inherited controlling TTY from stopping the probe while the parent waits.const output = execFile(shell, ["-ilc", buildEnvironmentCaptureCommand(names)], {encoding: "utf8",timeout: 5000,+ detached: true,+ stdio: ["ignore", "pipe", "ignore"],});const environment: Partial<Record<string, string>> = {};