mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-09 03:22:40 +00:00
fix(scripts): clamp parallels host timeouts
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user