fix(agents): clamp session suspension TTLs · openclaw/openclaw@11c050d
steipete
·
2026-05-31
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,6 +2,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
2 | 2 | import { DEFAULT_CRON_MAX_CONCURRENT_RUNS } from "../config/cron-limits.js"; |
3 | 3 | import type { OpenClawConfig } from "../config/types.openclaw.js"; |
4 | 4 | import { CommandLane } from "../process/lanes.js"; |
| 5 | +import { MAX_TIMER_TIMEOUT_MS } from "../shared/number-coercion.js"; |
5 | 6 | |
6 | 7 | const sessionStoreMocks = vi.hoisted(() => ({ |
7 | 8 | applySessionStoreEntryPatch: vi.fn(), |
@@ -102,6 +103,20 @@ describe("session suspension", () => {
|
102 | 103 | ); |
103 | 104 | }); |
104 | 105 | |
| 106 | +it("clamps oversized suspension TTLs for timers and persisted resume time", async () => { |
| 107 | +vi.useFakeTimers(); |
| 108 | +vi.setSystemTime(1_000); |
| 109 | +const setTimeoutSpy = vi.spyOn(globalThis, "setTimeout"); |
| 110 | + |
| 111 | +await suspendLane(Number.MAX_SAFE_INTEGER, {} as OpenClawConfig, CommandLane.Main); |
| 112 | + |
| 113 | +expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS); |
| 114 | +const patch = sessionStoreMocks.applySessionStoreEntryPatch.mock.calls[0]?.[0].patch as { |
| 115 | +quotaSuspension?: { expectedResumeBy?: number }; |
| 116 | +}; |
| 117 | +expect(patch.quotaSuspension?.expectedResumeBy).toBe(1_000 + MAX_TIMER_TIMEOUT_MS); |
| 118 | +}); |
| 119 | + |
105 | 120 | it("maps failover reasons to persisted suspension reasons", async () => { |
106 | 121 | const { testing } = await import("./session-suspension.js"); |
107 | 122 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。