




















@@ -49,7 +49,10 @@ async function waitForExit(
4949timeoutMs: number,
5050): Promise<{ signal: NodeJS.Signals | null; status: number | null }> {
5151return await new Promise((resolve, reject) => {
52-const timeout = setTimeout(() => reject(new Error("timeout waiting for child exit")), timeoutMs);
52+const timeout = setTimeout(
53+() => reject(new Error("timeout waiting for child exit")),
54+timeoutMs,
55+);
5356child.on("close", (status, signal) => {
5457clearTimeout(timeout);
5558resolve({ signal, status });
@@ -118,10 +121,9 @@ describe("package-openclaw-for-docker", () => {
118121const childPidPath = path.join(tempDir, "child.pid");
119122let childPid = 0;
120123try {
121-const childScript = [
122-"process.on('SIGTERM', () => {});",
123-"setInterval(() => {}, 1000);",
124-].join("");
124+const childScript = ["process.on('SIGTERM', () => {});", "setInterval(() => {}, 1000);"].join(
125+"",
126+);
125127const parentScript = [
126128"const { spawn } = require('node:child_process');",
127129"const fs = require('node:fs');",
@@ -135,13 +137,13 @@ describe("package-openclaw-for-docker", () => {
135137runCommandForTest(process.execPath, ["-e", parentScript], process.cwd(), {
136138env: { ...process.env, OPENCLAW_TEST_CHILD_PID: childPidPath },
137139killAfterMs: 50,
138-timeoutMs: 200,
140+timeoutMs: 2000,
139141}),
140-).rejects.toThrow(/timed out after 200ms/u);
142+).rejects.toThrow(/timed out after 2000ms/u);
141143144+await waitForFile(childPidPath, 2000);
142145childPid = Number(fs.readFileSync(childPidPath, "utf8"));
143-await new Promise((resolve) => setTimeout(resolve, 100));
144-expect(isProcessAlive(childPid)).toBe(false);
146+await waitForDead(childPid, 2000);
145147} finally {
146148if (childPid && isProcessAlive(childPid)) {
147149process.kill(childPid, "SIGKILL");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。