fix: retry lobster spawn on windows
This commit is contained in:
@@ -29,13 +29,22 @@ function resolveExecutablePath(lobsterPathRaw: string | undefined) {
|
|||||||
return lobsterPath;
|
return lobsterPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runLobsterSubprocess(params: {
|
function isWindowsSpawnEINVAL(err: unknown) {
|
||||||
execPath: string;
|
if (!err || typeof err !== "object") return false;
|
||||||
argv: string[];
|
const code = (err as { code?: unknown }).code;
|
||||||
cwd: string;
|
return code === "EINVAL";
|
||||||
timeoutMs: number;
|
}
|
||||||
maxStdoutBytes: number;
|
|
||||||
}) {
|
async function runLobsterSubprocessOnce(
|
||||||
|
params: {
|
||||||
|
execPath: string;
|
||||||
|
argv: string[];
|
||||||
|
cwd: string;
|
||||||
|
timeoutMs: number;
|
||||||
|
maxStdoutBytes: number;
|
||||||
|
},
|
||||||
|
useShell: boolean,
|
||||||
|
) {
|
||||||
const { execPath, argv, cwd } = params;
|
const { execPath, argv, cwd } = params;
|
||||||
const timeoutMs = Math.max(200, params.timeoutMs);
|
const timeoutMs = Math.max(200, params.timeoutMs);
|
||||||
const maxStdoutBytes = Math.max(1024, params.maxStdoutBytes);
|
const maxStdoutBytes = Math.max(1024, params.maxStdoutBytes);
|
||||||
@@ -51,6 +60,8 @@ async function runLobsterSubprocess(params: {
|
|||||||
cwd,
|
cwd,
|
||||||
stdio: ["ignore", "pipe", "pipe"],
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
env,
|
env,
|
||||||
|
shell: useShell,
|
||||||
|
windowsHide: useShell ? true : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
let stdout = "";
|
let stdout = "";
|
||||||
@@ -102,6 +113,23 @@ async function runLobsterSubprocess(params: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function runLobsterSubprocess(params: {
|
||||||
|
execPath: string;
|
||||||
|
argv: string[];
|
||||||
|
cwd: string;
|
||||||
|
timeoutMs: number;
|
||||||
|
maxStdoutBytes: number;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
return await runLobsterSubprocessOnce(params, false);
|
||||||
|
} catch (err) {
|
||||||
|
if (process.platform === "win32" && isWindowsSpawnEINVAL(err)) {
|
||||||
|
return await runLobsterSubprocessOnce(params, true);
|
||||||
|
}
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function parseEnvelope(stdout: string): LobsterEnvelope {
|
function parseEnvelope(stdout: string): LobsterEnvelope {
|
||||||
let parsed: unknown;
|
let parsed: unknown;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -253,10 +253,7 @@ describe("exec approvals default agent migration", () => {
|
|||||||
};
|
};
|
||||||
const resolved = resolveExecApprovalsFromFile({ file });
|
const resolved = resolveExecApprovalsFromFile({ file });
|
||||||
expect(resolved.agent.ask).toBe("always");
|
expect(resolved.agent.ask).toBe("always");
|
||||||
expect(resolved.allowlist.map((entry) => entry.pattern)).toEqual([
|
expect(resolved.allowlist.map((entry) => entry.pattern)).toEqual(["/bin/main", "/bin/legacy"]);
|
||||||
"/bin/main",
|
|
||||||
"/bin/legacy",
|
|
||||||
]);
|
|
||||||
expect(resolved.file.agents?.default).toBeUndefined();
|
expect(resolved.file.agents?.default).toBeUndefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user