Skip to content

Commit 7a12ed1

Browse files
committed
fix(server): force-stop timed out login shell probes
1 parent 949feb6 commit 7a12ed1

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,27 @@ describe("readPathFromLoginShell", () => {
6363
(
6464
file: string,
6565
args: ReadonlyArray<string>,
66-
options: { encoding: "utf8"; timeout: number },
66+
options: {
67+
encoding: "utf8";
68+
timeout: number;
69+
killSignal?: NodeJS.Signals | number;
70+
},
6771
) => string
6872
>(() => "__T3CODE_ENV_PATH_START__\n/a:/b\n__T3CODE_ENV_PATH_END__\n");
6973

7074
expect(readPathFromLoginShell("/opt/homebrew/bin/fish", execFile)).toBe("/a:/b");
7175
expect(execFile).toHaveBeenCalledTimes(1);
7276

7377
const firstCall = execFile.mock.calls[0] as
74-
| [string, ReadonlyArray<string>, { encoding: "utf8"; timeout: number }]
78+
| [
79+
string,
80+
ReadonlyArray<string>,
81+
{
82+
encoding: "utf8";
83+
timeout: number;
84+
killSignal?: NodeJS.Signals | number;
85+
},
86+
]
7587
| undefined;
7688
expect(firstCall).toBeDefined();
7789
if (!firstCall) {
@@ -85,7 +97,7 @@ describe("readPathFromLoginShell", () => {
8597
expect(args?.[1]).toContain("printenv PATH || true");
8698
expect(args?.[1]).toContain("__T3CODE_ENV_PATH_START__");
8799
expect(args?.[1]).toContain("__T3CODE_ENV_PATH_END__");
88-
expect(options).toEqual({ encoding: "utf8", timeout: 5000 });
100+
expect(options).toEqual({ encoding: "utf8", timeout: 5000, killSignal: "SIGKILL" });
89101
});
90102
});
91103

‎packages/shared/src/shell.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const WINDOWS_SHELL_CANDIDATES = ["pwsh.exe", "powershell.exe"] as const;
2222
type ExecFileSyncLike = (
2323
file: string,
2424
args: ReadonlyArray<string>,
25-
options: { encoding: "utf8"; timeout: number },
25+
options: { encoding: "utf8"; timeout: number; killSignal?: NodeJS.Signals | number },
2626
) => string;
2727

2828
function canExecuteFile(filePath: string): boolean {
@@ -315,6 +315,7 @@ export const readEnvironmentFromLoginShell: ShellEnvironmentReader = (
315315
const output = execFile(shell, ["-ilc", buildEnvironmentCaptureCommand(names)], {
316316
encoding: "utf8",
317317
timeout: 5000,
318+
killSignal: "SIGKILL",
318319
});
319320

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

0 commit comments

Comments
 (0)