Skip to content

Commit 29eba5a

Browse files
committed
fix(test): clamp qa otel child timer
1 parent b99812b commit 29eba5a

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

test/e2e/qa-lab/runtime/qa-otel-smoke-runtime.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { tmpdir } from "node:os";
1010
import path from "node:path";
1111
import { pathToFileURL } from "node:url";
1212
import { gunzipSync } from "node:zlib";
13+
import { resolveTimerTimeoutMs } from "@openclaw/normalization-core/number-coercion";
1314
import { stripLeadingPackageManagerSeparator } from "../../../../scripts/lib/arg-utils.mjs";
1415
import { resolveWindowsTaskkillPath } from "../../../../scripts/lib/windows-taskkill.mjs";
1516

@@ -1275,12 +1276,13 @@ async function waitForChild(
12751276
timeoutMs = QA_SUITE_TIMEOUT_MS,
12761277
killGraceMs = QA_SUITE_KILL_GRACE_MS,
12771278
): Promise<number> {
1279+
const resolvedTimeoutMs = resolveTimerTimeoutMs(timeoutMs, QA_SUITE_TIMEOUT_MS);
12781280
const childExit = new Promise<number>((resolve) => {
12791281
child.once("close", (code) => resolve(code ?? 1));
12801282
});
12811283
let timeoutHandle: NodeJS.Timeout | undefined;
12821284
const timeout = new Promise<"timeout">((resolve) => {
1283-
timeoutHandle = setTimeout(() => resolve("timeout"), timeoutMs);
1285+
timeoutHandle = setTimeout(() => resolve("timeout"), resolvedTimeoutMs);
12841286
timeoutHandle.unref();
12851287
});
12861288
const result = await Promise.race([childExit, timeout]).finally(() => {
@@ -1298,7 +1300,7 @@ async function waitForChild(
12981300
terminateChildTree(child, "SIGKILL", cleanupPids);
12991301
await waitForProcessTreeExit(child, 1000, cleanupPids);
13001302
}
1301-
throw new Error(`openclaw qa suite timed out after ${timeoutMs}ms`);
1303+
throw new Error(`openclaw qa suite timed out after ${resolvedTimeoutMs}ms`);
13021304
}
13031305

13041306
function collectChildProcessTreePids(child: ChildProcess): number[] {

test/e2e/qa-lab/runtime/qa-otel-smoke.e2e.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import os from "node:os";
77
import path from "node:path";
88
import { setTimeout as delay } from "node:timers/promises";
99
import { gzipSync } from "node:zlib";
10+
import { MAX_TIMER_TIMEOUT_MS } from "@openclaw/normalization-core/number-coercion";
1011
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
1112
import { resolveWindowsTaskkillPath } from "../../../../scripts/lib/windows-taskkill.mjs";
1213
import { testing } from "./qa-otel-smoke-runtime.js";
@@ -662,6 +663,16 @@ describe("qa-otel-smoke receiver bounds", () => {
662663
}
663664
});
664665

666+
it("clamps oversized QA suite child timers before scheduling", async () => {
667+
const child = spawn(
668+
process.execPath,
669+
["--input-type=module", "--eval", "setTimeout(() => process.exit(0), 25);"],
670+
{ stdio: "ignore" },
671+
);
672+
673+
await expect(testing.waitForChild(child, MAX_TIMER_TIMEOUT_MS + 1, 100)).resolves.toBe(0);
674+
});
675+
665676
it("uses taskkill for Windows QA suite timeout cleanup", () => {
666677
const kill = vi.fn();
667678
const runTaskkill = vi.fn(() => ({ status: 0 }));

0 commit comments

Comments
 (0)