mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 21:07:01 -06:00
perf(test): unref process watchdogs (#108643)
This commit is contained in:
committed by
GitHub
parent
7a398fe6f8
commit
fecd11fdc9
@@ -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");
|
||||
}),
|
||||
]);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
}),
|
||||
]);
|
||||
|
||||
@@ -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();
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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");
|
||||
}),
|
||||
]),
|
||||
|
||||
@@ -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");
|
||||
}),
|
||||
]);
|
||||
|
||||
@@ -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");
|
||||
}),
|
||||
]);
|
||||
|
||||
@@ -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");
|
||||
}),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user