






















@@ -241,18 +241,18 @@ describe("scripts/lib/openclaw-e2e-instance.sh", () => {
241241}
242242});
243243244-it("fails package installs when no timeout binary is available", () => {
244+it("uses the Node watchdog when timeout is unavailable", () => {
245245const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-e2e-instance-no-timeout-"));
246246try {
247247const npmArgsPath = path.join(tempDir, "npm-args.txt");
248248const logPath = path.join(tempDir, "install.log");
249249const packagePath = path.join(tempDir, "openclaw.tgz");
250+const nodeBinDir = path.dirname(process.execPath);
250251fs.writeFileSync(packagePath, "");
251252fs.writeFileSync(
252253path.join(tempDir, "npm"),
253254["#!/bin/sh", "set -eu", 'printf "%s\\n" "$*" >"$OPENCLAW_TEST_NPM_ARGS"', ""].join("\n"),
254255);
255-fs.symlinkSync("/bin/cat", path.join(tempDir, "cat"));
256256fs.chmodSync(path.join(tempDir, "npm"), 0o755);
257257258258const result = spawnSync(
@@ -269,23 +269,54 @@ describe("scripts/lib/openclaw-e2e-instance.sh", () => {
269269encoding: "utf8",
270270env: {
271271 ...process.env,
272-PATH: tempDir,
272+PATH: `${tempDir}:${nodeBinDir}`,
273273OPENCLAW_CURRENT_PACKAGE_TGZ: packagePath,
274274OPENCLAW_E2E_NPM_INSTALL_TIMEOUT: "42s",
275275OPENCLAW_TEST_NPM_ARGS: npmArgsPath,
276276},
277277},
278278);
279279280-expect(result.status).not.toBe(0);
281-expect(result.stderr).toContain(
282-"timeout or gtimeout is required for OpenClaw E2E command timeout 42s",
280+expect(result.status).toBe(0);
281+expect(fs.readFileSync(logPath, "utf8")).toContain("using Node watchdog");
282+expect(fs.readFileSync(npmArgsPath, "utf8").trim()).toBe(
283+`install -g ${packagePath} --no-fund --no-audit`,
283284);
284-expect(result.stderr).toContain("npm install failed for fixture package");
285-expect(fs.readFileSync(logPath, "utf8")).toContain(
286-"timeout or gtimeout is required for OpenClaw E2E command timeout 42s",
285+} finally {
286+fs.rmSync(tempDir, { force: true, recursive: true });
287+}
288+});
289+290+it("bounds commands with the Node watchdog when timeout is unavailable", () => {
291+const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-e2e-instance-node-watchdog-"));
292+try {
293+const nodeBinDir = path.dirname(process.execPath);
294+const startedAt = Date.now();
295+const result = spawnSync(
296+"/bin/bash",
297+[
298+"-c",
299+[
300+"set -euo pipefail",
301+`source ${shellQuote(helperPath)}`,
302+`openclaw_e2e_maybe_timeout 200ms ${shellQuote(process.execPath)} -e ${shellQuote("setInterval(() => {}, 1000)")}`,
303+].join("; "),
304+],
305+{
306+encoding: "utf8",
307+env: {
308+ ...process.env,
309+PATH: `${tempDir}:${nodeBinDir}`,
310+},
311+timeout: 5_000,
312+},
287313);
288-expect(fs.existsSync(npmArgsPath)).toBe(false);
314+const elapsedMs = Date.now() - startedAt;
315+316+expect(result.status).toBe(124);
317+expect(elapsedMs).toBeLessThan(4_000);
318+expect(result.stderr).toContain("using Node watchdog");
319+expect(result.stderr).toContain("OpenClaw E2E command timed out after 200ms");
289320} finally {
290321fs.rmSync(tempDir, { force: true, recursive: true });
291322}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。