fix(daemon): bound Node runtime probes (#109127)

This commit is contained in:
Alix-007
2026-07-16 09:00:06 -07:00
committed by GitHub
parent 243beca126
commit 2d0f0d0ec0
2 changed files with 8 additions and 5 deletions
+2 -2
View File
@@ -219,7 +219,7 @@ describe("resolvePreferredNodePath", () => {
expect(execFile).toHaveBeenCalledWith(
darwinNode,
["-e", expect.stringContaining("SELECT sqlite_version() AS version")],
{ encoding: "utf8" },
{ encoding: "utf8", timeoutMs: 5_000 },
);
});
@@ -462,7 +462,7 @@ describe("resolveSystemNodeInfo", () => {
expect(execFile).toHaveBeenCalledWith(
homebrewOptNode,
["-e", expect.stringContaining("SELECT sqlite_version() AS version")],
{ encoding: "utf8" },
{ encoding: "utf8", timeoutMs: 5_000 },
);
});
+6 -3
View File
@@ -75,11 +75,13 @@ function buildSystemNodeCandidates(
type ExecFileAsync = (
file: string,
args: readonly string[],
options: { encoding: "utf8" },
options: { encoding: "utf8"; timeoutMs: number },
) => Promise<{ stdout: string; stderr: string }>;
const execFileAsync: ExecFileAsync = async (file, args) =>
await runExec(file, [...args], { logOutput: false });
const NODE_RUNTIME_PROBE_TIMEOUT_MS = 5_000;
const execFileAsync: ExecFileAsync = async (file, args, options) =>
await runExec(file, [...args], { logOutput: false, timeoutMs: options.timeoutMs });
const NODE_RUNTIME_PROBE = String.raw`
let sqliteVersion = null;
@@ -108,6 +110,7 @@ async function resolveNodeRuntimeInfo(
try {
const { stdout } = await execFileImpl(nodePath, ["-e", NODE_RUNTIME_PROBE], {
encoding: "utf8",
timeoutMs: NODE_RUNTIME_PROBE_TIMEOUT_MS,
});
const parsed = JSON.parse(stdout) as {
nodeVersion?: unknown;