























1-import { mkdtempSync, readFileSync } from "node:fs";
1+import { mkdtempSync, readFileSync, rmSync } from "node:fs";
22import { tmpdir } from "node:os";
33import path from "node:path";
44import process from "node:process";
@@ -67,30 +67,34 @@ describe("control-ui-i18n process runner", () => {
6767"kills descendant processes after the process timeout",
6868async () => {
6969const tempDir = mkdtempSync(path.join(tmpdir(), "openclaw-control-ui-i18n-timeout-"));
70-const markerPath = path.join(tempDir, "grandchild.pid");
71-const grandchildScript = [
72-"process.on('SIGTERM', () => {});",
73-"setInterval(() => {}, 1000);",
74-].join("\n");
75-const parentScript = [
76-"const { spawn } = require('node:child_process');",
77-"const { writeFileSync } = require('node:fs');",
78-`const grandchild = spawn(process.execPath, ["-e", ${JSON.stringify(grandchildScript)}], { stdio: "ignore" });`,
79-`writeFileSync(${JSON.stringify(markerPath)}, String(grandchild.pid));`,
80-"process.on('SIGTERM', () => {});",
81-"setInterval(() => {}, 1000);",
82-].join("\n");
70+try {
71+const markerPath = path.join(tempDir, "grandchild.pid");
72+const grandchildScript = [
73+"process.on('SIGTERM', () => {});",
74+"setInterval(() => {}, 1000);",
75+].join("\n");
76+const parentScript = [
77+"const { spawn } = require('node:child_process');",
78+"const { writeFileSync } = require('node:fs');",
79+`const grandchild = spawn(process.execPath, ["-e", ${JSON.stringify(grandchildScript)}], { stdio: "ignore" });`,
80+`writeFileSync(${JSON.stringify(markerPath)}, String(grandchild.pid));`,
81+"process.on('SIGTERM', () => {});",
82+"setInterval(() => {}, 1000);",
83+].join("\n");
838484-await expect(
85-runProcess(process.execPath, ["-e", parentScript], {
86-cwd: tempDir,
87-killGraceMs: 25,
88-timeoutMs: 500,
89-}),
90-).rejects.toThrow(`timed out after 500ms`);
85+ await expect(
86+ runProcess(process.execPath, ["-e", parentScript], {
87+ cwd: tempDir,
88+ killGraceMs: 25,
89+ timeoutMs: 500,
90+ }),
91+ ).rejects.toThrow(`timed out after 500ms`);
919292-const grandchildPid = Number(readFileSync(markerPath, "utf8"));
93-await waitForProcessExit(grandchildPid);
93+const grandchildPid = Number(readFileSync(markerPath, "utf8"));
94+await waitForProcessExit(grandchildPid);
95+} finally {
96+rmSync(tempDir, { force: true, recursive: true });
97+}
9498},
9599);
96100});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。