perf(test): unref process watchdogs (#108643)

This commit is contained in:
Peter Steinberger
2026-07-16 00:39:08 -07:00
committed by GitHub
parent 7a398fe6f8
commit fecd11fdc9
12 changed files with 18 additions and 14 deletions
@@ -331,13 +331,13 @@ describe("qa-otel-smoke receiver bounds", () => {
await Promise.race([
receiver.close(),
delay(1_000).then(() => {
delay(1_000, undefined, { ref: false }).then(() => {
throw new Error("receiver close timed out");
}),
]);
await Promise.race([
socketClosed,
delay(1_000).then(() => {
delay(1_000, undefined, { ref: false }).then(() => {
throw new Error("socket close timed out");
}),
]);
+1 -1
View File
@@ -37,7 +37,7 @@ async function stopServer(child: FixtureServerChild) {
child.once("exit", () => resolve());
});
child.kill("SIGTERM");
await Promise.race([exited, delay(1_000)]);
await Promise.race([exited, delay(1_000, undefined, { ref: false })]);
if (child.exitCode === null && child.signalCode === null) {
child.kill("SIGKILL");
await exited;
+1 -1
View File
@@ -599,7 +599,7 @@ async function waitForProcessExit(
child.once("error", reject);
child.once("exit", (status, signal) => resolve({ status, signal }));
}),
delay(timeoutMs).then(() => {
delay(timeoutMs, undefined, { ref: false }).then(() => {
throw new Error("timed out waiting for wrapper process exit");
}),
]);
+5 -1
View File
@@ -103,7 +103,11 @@ async function waitForChildExit(
child.once("exit", (status, signal) => resolve({ status, signal }));
}),
new Promise<never>((_, reject) => {
setTimeout(() => reject(new Error("timed out waiting for child exit")), timeoutMs);
const timer = setTimeout(
() => reject(new Error("timed out waiting for child exit")),
timeoutMs,
);
timer.unref();
}),
]);
}
+1 -1
View File
@@ -91,7 +91,7 @@ async function stopServer(child: ChildProcess) {
child.kill("SIGTERM");
await Promise.race([
exited,
delay(1_000).then(() => {
delay(1_000, undefined, { ref: false }).then(() => {
if (child.exitCode === null && child.signalCode === null) {
child.kill("SIGKILL");
}
@@ -1068,13 +1068,13 @@ describe("scripts/openclaw-cross-os-release-checks", () => {
socket.write(`GET ${url.pathname} HTTP/1.1\r\nHost: ${url.host}\r\n\r\n`);
await Promise.race([
server.close(),
delay(1_000).then(() => {
delay(1_000, undefined, { ref: false }).then(() => {
throw new Error("close timed out");
}),
]);
await Promise.race([
socketClosePromise,
delay(1_000).then(() => {
delay(1_000, undefined, { ref: false }).then(() => {
throw new Error("socket close timed out");
}),
]);
@@ -93,7 +93,7 @@ async function waitForProcessExit(
const exit = new Promise<{ code: number | null; signal: NodeJS.Signals | null }>((resolve) => {
child.once("exit", (code, signal) => resolve({ code, signal }));
});
const timeout = delay(timeoutMs).then(() => {
const timeout = delay(timeoutMs, undefined, { ref: false }).then(() => {
throw new Error(`Process ${child.pid ?? "unknown"} did not exit after ${timeoutMs}ms`);
});
return Promise.race([exit, timeout]);
+1 -1
View File
@@ -1025,7 +1025,7 @@ async function waitForClose(child: ReturnType<typeof spawn>, timeoutMs = 5_000)
new Promise<{ code: number | null; signal: NodeJS.Signals | null }>((resolve) => {
child.once("close", (code, signal) => resolve({ code, signal }));
}),
delay(timeoutMs).then(() => {
delay(timeoutMs, undefined, { ref: false }).then(() => {
throw new Error("timed out waiting for child close");
}),
]);
@@ -861,7 +861,7 @@ fs.writeFileSync(${JSON.stringify(recorderExitPath)}, "exited");
startDelayMs: 0,
target: "linux",
}),
delay(500).then(() => {
delay(500, undefined, { ref: false }).then(() => {
throw new Error("recordProbeVideo hung after the recorder had already exited");
}),
]),
+1 -1
View File
@@ -1005,7 +1005,7 @@ async function waitForClose(
new Promise<{ code: number | null; signal: NodeJS.Signals | null }>((resolve) => {
child.once("close", (code, signal) => resolve({ code, signal }));
}),
delay(timeoutMs).then(() => {
delay(timeoutMs, undefined, { ref: false }).then(() => {
throw new Error("timed out waiting for child close");
}),
]);
+1 -1
View File
@@ -580,7 +580,7 @@ async function waitForClose(
new Promise<{ code: number | null; signal: NodeJS.Signals | null }>((resolve) => {
child.once("close", (code, signal) => resolve({ code, signal }));
}),
delay(timeoutMs).then(() => {
delay(timeoutMs, undefined, { ref: false }).then(() => {
throw new Error("timed out waiting for child close");
}),
]);
+1 -1
View File
@@ -258,7 +258,7 @@ async function waitForClose(child: ReturnType<typeof spawn>, timeoutMs = 5_000)
new Promise<{ code: number | null; signal: NodeJS.Signals | null }>((resolve) => {
child.once("close", (code, signal) => resolve({ code, signal }));
}),
delay(timeoutMs).then(() => {
delay(timeoutMs, undefined, { ref: false }).then(() => {
throw new Error("timed out waiting for child close");
}),
]);