Skip to content

Commit 7f63b10

Browse files
LouisDeconinckdevin-ai-integration[bot]juliusmarminge
authored
fix(shell): avoid interactive job control in environment probes (pingdotgg#11275)
Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Julius Marminge <[email protected]>
1 parent 729924a commit 7f63b10

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎packages/shared/src/shell.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ describe("readEnvironmentFromLoginShell probe", () => {
8787
expect(args?.[1]).toContain("printenv PATH || true");
8888
expect(args?.[1]).toContain("__T3CODE_ENV_PATH_START__");
8989
expect(args?.[1]).toContain("__T3CODE_ENV_PATH_END__");
90-
expect(options).toEqual({ encoding: "utf8", timeout: 5000 });
90+
expect(options).toEqual({
91+
encoding: "utf8",
92+
timeout: 5000,
93+
detached: true,
94+
stdio: ["ignore", "pipe", "ignore"],
95+
});
9196
});
9297
});
9398

‎packages/shared/src/shell.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ const WINDOWS_SHELL_CANDIDATES = ["pwsh.exe", "powershell.exe"] as const;
2020
type ExecFileSyncLike = (
2121
file: string,
2222
args: ReadonlyArray<string>,
23-
options: { encoding: "utf8"; timeout: number },
23+
options: {
24+
encoding: "utf8";
25+
timeout: number;
26+
detached?: true;
27+
stdio?: ["ignore", "pipe", "ignore"];
28+
},
2429
) => string;
2530

2631
function canExecuteFile(filePath: string): boolean {
@@ -268,9 +273,13 @@ export const readEnvironmentFromLoginShell: ShellEnvironmentReader = (
268273
return {};
269274
}
270275

276+
// Interactive startup loads PATH entries; detaching prevents job control on an
277+
// inherited controlling TTY from stopping the probe while the parent waits.
271278
const output = execFile(shell, ["-ilc", buildEnvironmentCaptureCommand(names)], {
272279
encoding: "utf8",
273280
timeout: 5000,
281+
detached: true,
282+
stdio: ["ignore", "pipe", "ignore"],
274283
});
275284

276285
const environment: Partial<Record<string, string>> = {};

0 commit comments

Comments
 (0)