mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-04 01:34:06 +00:00
fix(feishu): clamp abortable delay timers
This commit is contained in:
@@ -49,4 +49,19 @@ describe("waitForAbortableDelay", () => {
|
||||
|
||||
await expect(delay).resolves.toBe(true);
|
||||
});
|
||||
|
||||
it("normalizes oversized delays before arming the timer", async () => {
|
||||
const timeoutSpy = vi
|
||||
.spyOn(globalThis, "setTimeout")
|
||||
.mockImplementation((callback: () => void) => {
|
||||
queueMicrotask(callback);
|
||||
return 1 as unknown as ReturnType<typeof setTimeout>;
|
||||
});
|
||||
vi.spyOn(globalThis, "clearTimeout").mockImplementation(() => undefined);
|
||||
|
||||
const delay = waitForAbortableDelay(Number.MAX_SAFE_INTEGER);
|
||||
|
||||
expect(timeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS);
|
||||
await expect(delay).resolves.toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -101,7 +101,7 @@ export function waitForAbortableDelay(
|
||||
return;
|
||||
}
|
||||
|
||||
timer = setTimeout(() => finish(true), delayMs);
|
||||
timer = setTimeout(() => finish(true), resolveTimerTimeoutMs(delayMs, 1));
|
||||
timer.unref?.();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user