fix(exec): normalize unsafe timeout values · openclaw/openclaw@95e898b
steipete
·
2026-05-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
| 2 | +import { MAX_SAFE_TIMEOUT_DELAY_MS } from "../utils/timer-delay.js"; |
2 | 3 | |
3 | 4 | const requestHeartbeatMock = vi.hoisted(() => vi.fn()); |
4 | 5 | const enqueueSystemEventMock = vi.hoisted(() => vi.fn()); |
@@ -720,6 +721,48 @@ describe("buildExecExitOutcome", () => {
|
720 | 721 | }); |
721 | 722 | |
722 | 723 | describe("runExecProcess POSIX command wrapper", () => { |
| 724 | +it("normalizes non-finite and oversized exec timeouts before spawning", async () => { |
| 725 | +supervisorMock.spawn.mockResolvedValue({ |
| 726 | +runId: "mock-run", |
| 727 | +startedAtMs: Date.now(), |
| 728 | +wait: async () => ({ |
| 729 | +reason: "exit", |
| 730 | +exitCode: 0, |
| 731 | +exitSignal: null, |
| 732 | +durationMs: 0, |
| 733 | +stdout: "", |
| 734 | +stderr: "", |
| 735 | +timedOut: false, |
| 736 | +noOutputTimedOut: false, |
| 737 | +}), |
| 738 | +cancel: vi.fn(), |
| 739 | +}); |
| 740 | + |
| 741 | +const baseParams = { |
| 742 | +command: "echo test", |
| 743 | +workdir: "/tmp", |
| 744 | +env: { PATH: "/usr/bin" }, |
| 745 | +pathPrepend: [], |
| 746 | +usePty: false, |
| 747 | +warnings: [], |
| 748 | +maxOutput: 1000, |
| 749 | +pendingMaxOutput: 1000, |
| 750 | +notifyOnExit: false, |
| 751 | +}; |
| 752 | + |
| 753 | +await runExecProcess({ |
| 754 | + ...baseParams, |
| 755 | +timeoutSec: Number.POSITIVE_INFINITY, |
| 756 | +}); |
| 757 | +await runExecProcess({ |
| 758 | + ...baseParams, |
| 759 | +timeoutSec: 3_000_000, |
| 760 | +}); |
| 761 | + |
| 762 | +expect(supervisorMock.spawn.mock.calls[0]?.[0].timeoutMs).toBeUndefined(); |
| 763 | +expect(supervisorMock.spawn.mock.calls[1]?.[0].timeoutMs).toBe(MAX_SAFE_TIMEOUT_DELAY_MS); |
| 764 | +}); |
| 765 | + |
723 | 766 | it("wraps command with PATH export if OPENCLAW_PREPEND_PATH is present", async () => { |
724 | 767 | if (process.platform === "win32") { |
725 | 768 | return; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。