fix(scripts): clamp parallels host timeouts

This commit is contained in:
Vincent Koc
2026-06-22 02:18:48 +02:00
parent 4cb94cc2cf
commit 790dfb66a8
2 changed files with 54 additions and 12 deletions

View File

@@ -17,6 +17,7 @@ import { tmpdir } from "node:os";
import { basename, delimiter, join, win32 } from "node:path";
import { setTimeout as delay } from "node:timers/promises";
import { pathToFileURL } from "node:url";
import { MAX_TIMER_TIMEOUT_MS } from "@openclaw/normalization-core/number-coercion";
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
import {
extractLastOpenClawVersionFromLog,
@@ -1466,6 +1467,16 @@ if (isPrlctl) {
expect(result.stdout).toBeTypeOf("string");
});
it("clamps oversized timed host command wrapper timeouts", () => {
const result = run(process.execPath, ["-e", "setTimeout(() => process.exit(0), 25);"], {
check: false,
quiet: true,
timeoutMs: MAX_TIMER_TIMEOUT_MS + 1,
});
expect(result.status).toBe(0);
});
it.runIf(process.platform !== "win32")(
"lets timed host command descendants drain before force kill",
() => {
@@ -1684,6 +1695,21 @@ setInterval(() => {}, 1000);
}
});
it("clamps oversized streaming host command timeouts before arming timers", async () => {
const setTimeoutSpy = vi.spyOn(globalThis, "setTimeout");
try {
await expect(
runStreaming(process.execPath, ["-e", "setTimeout(() => process.exit(0), 25);"], {
quiet: true,
timeoutMs: MAX_TIMER_TIMEOUT_MS + 1,
}),
).resolves.toBe(0);
expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS);
} finally {
setTimeoutSpy.mockRestore();
}
});
it.runIf(process.platform !== "win32")(
"lets timed streaming host command descendants drain before force kill",
async () => {