fix(channels): clamp draft stream throttles · openclaw/openclaw@764321d
steipete
·
2026-05-31
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { describe, expect, it, vi } from "vitest"; |
| 2 | +import { MAX_TIMER_TIMEOUT_MS } from "../shared/number-coercion.js"; |
2 | 3 | import { createDraftStreamLoop } from "./draft-stream-loop.js"; |
3 | 4 | |
4 | 5 | const flushMicrotasks = async () => { |
@@ -94,6 +95,26 @@ describe("createDraftStreamLoop", () => {
|
94 | 95 | } |
95 | 96 | }); |
96 | 97 | |
| 98 | +it("clamps oversized throttle timers", () => { |
| 99 | +vi.useFakeTimers(); |
| 100 | +try { |
| 101 | +vi.setSystemTime(0); |
| 102 | +const setTimeoutSpy = vi.spyOn(globalThis, "setTimeout"); |
| 103 | +const loop = createDraftStreamLoop({ |
| 104 | +throttleMs: Number.MAX_SAFE_INTEGER, |
| 105 | +isStopped: () => false, |
| 106 | +sendOrEditStreamMessage: vi.fn(async () => true), |
| 107 | +}); |
| 108 | + |
| 109 | +loop.update("hello"); |
| 110 | + |
| 111 | +expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS); |
| 112 | +loop.stop(); |
| 113 | +} finally { |
| 114 | +vi.useRealTimers(); |
| 115 | +} |
| 116 | +}); |
| 117 | + |
97 | 118 | it("contains synchronous sender failures from background flushes", async () => { |
98 | 119 | await captureUnhandledRejections(async (rejections) => { |
99 | 120 | const error = new Error("send failed"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。