fix(feishu): cap async helper timeouts · openclaw/openclaw@95f9231
steipete
·
2026-05-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { MAX_TIMER_TIMEOUT_MS } from "openclaw/plugin-sdk/number-runtime"; |
1 | 2 | import { afterEach, describe, expect, it, vi } from "vitest"; |
2 | | -import { waitForAbortableDelay } from "./async.js"; |
| 3 | +import { raceWithTimeoutAndAbort, waitForAbortableDelay } from "./async.js"; |
3 | 4 | |
4 | 5 | afterEach(() => { |
5 | 6 | vi.useRealTimers(); |
| 7 | +vi.restoreAllMocks(); |
| 8 | +}); |
| 9 | + |
| 10 | +describe("raceWithTimeoutAndAbort", () => { |
| 11 | +it("normalizes oversized timeouts before arming the watchdog", async () => { |
| 12 | +const timeoutSpy = vi |
| 13 | +.spyOn(globalThis, "setTimeout") |
| 14 | +.mockReturnValue(1 as unknown as ReturnType<typeof setTimeout>); |
| 15 | +vi.spyOn(globalThis, "clearTimeout").mockImplementation(() => undefined); |
| 16 | + |
| 17 | +await raceWithTimeoutAndAbort(Promise.resolve("ok"), { |
| 18 | +timeoutMs: Number.MAX_SAFE_INTEGER, |
| 19 | +}); |
| 20 | + |
| 21 | +expect(timeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS); |
| 22 | +}); |
6 | 23 | }); |
7 | 24 | |
8 | 25 | describe("waitForAbortableDelay", () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。