fix(sqlite): clamp WAL checkpoint intervals · openclaw/openclaw@287f531
steipete
·
2026-05-31
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import type { DatabaseSync } from "node:sqlite"; |
2 | 2 | import { afterEach, describe, expect, it, vi } from "vitest"; |
| 3 | +import { MAX_TIMER_TIMEOUT_MS } from "../shared/number-coercion.js"; |
3 | 4 | import { |
4 | 5 | DEFAULT_SQLITE_WAL_AUTOCHECKPOINT_PAGES, |
5 | 6 | configureSqliteWalMaintenance, |
@@ -46,6 +47,19 @@ describe("sqlite WAL maintenance", () => {
|
46 | 47 | expect(db.exec).toHaveBeenCalledTimes(4); |
47 | 48 | }); |
48 | 49 | |
| 50 | +it("clamps oversized checkpoint intervals before arming timers", () => { |
| 51 | +vi.useFakeTimers(); |
| 52 | +const setIntervalSpy = vi.spyOn(globalThis, "setInterval"); |
| 53 | +const db = createMockDb(); |
| 54 | + |
| 55 | +const maintenance = configureSqliteWalMaintenance(db, { |
| 56 | +checkpointIntervalMs: Number.MAX_SAFE_INTEGER, |
| 57 | +}); |
| 58 | + |
| 59 | +expect(setIntervalSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS); |
| 60 | +maintenance.close(); |
| 61 | +}); |
| 62 | + |
49 | 63 | it("reports checkpoint errors without throwing from background maintenance", () => { |
50 | 64 | const db = createMockDb(); |
51 | 65 | const error = new Error("busy"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。