惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks
B
Blog
腾讯CDC
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - Franky
罗磊的独立博客
月光博客
月光博客
Jina AI
Jina AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
D
Docker
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
G
Google Developers Blog
V
Visual Studio Blog
I
InfoQ
有赞技术团队
有赞技术团队
D
DataBreaches.Net
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
阮一峰的网络日志
阮一峰的网络日志
宝玉的分享
宝玉的分享
Blog — PlanetScale
Blog — PlanetScale

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(nostr): bound seen tracker timer options (#97133) · o...
zhangguiping · 2026-06-27 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -232,6 +232,55 @@ describe("SeenTracker", () => {

232232

tracker.stop();

233233

vi.useRealTimers();

234234

});

235+
236+

it.each([-1, 0])("falls back to default TTL for non-positive ttlMs %s", (ttlMs) => {

237+

vi.useFakeTimers();

238+

const tracker = createTracker({ ttlMs, pruneIntervalMs: 10 * 60 * 1000 });

239+
240+

try {

241+

tracker.add("id1");

242+

vi.advanceTimersByTime(1);

243+

expect(tracker.peek("id1")).toBe(true);

244+

} finally {

245+

tracker.stop();

246+

vi.useRealTimers();

247+

}

248+

});

249+
250+

it("falls back to default TTL for infinite ttlMs", () => {

251+

vi.useFakeTimers();

252+

const tracker = createTracker({

253+

ttlMs: Number.POSITIVE_INFINITY,

254+

pruneIntervalMs: 10 * 60 * 1000,

255+

});

256+
257+

try {

258+

tracker.add("id1");

259+

vi.advanceTimersByTime(60 * 60 * 1000 + 1);

260+

expect(tracker.peek("id1")).toBe(false);

261+

} finally {

262+

tracker.stop();

263+

vi.useRealTimers();

264+

}

265+

});

266+
267+

it.each([-1, 0, Number.POSITIVE_INFINITY])(

268+

"uses the default prune interval for unsafe pruneIntervalMs %s",

269+

(pruneIntervalMs) => {

270+

vi.useFakeTimers();

271+

const setIntervalSpy = vi.spyOn(globalThis, "setInterval");

272+

const tracker = createTracker({ pruneIntervalMs });

273+
274+

try {

275+

expect(setIntervalSpy).toHaveBeenCalledTimes(1);

276+

expect(setIntervalSpy.mock.calls[0]?.[1]).toBe(10 * 60 * 1000);

277+

} finally {

278+

tracker.stop();

279+

setIntervalSpy.mockRestore();

280+

vi.useRealTimers();

281+

}

282+

},

283+

);

235284

});

236285

});

237286
Original file line numberDiff line numberDiff line change

@@ -3,7 +3,10 @@

33

* Prevents unbounded memory growth under high load or abuse.

44

*/

55
6-

import { resolveIntegerOption } from "openclaw/plugin-sdk/number-runtime";

6+

import {

7+

resolveIntegerOption,

8+

resolvePositiveTimerTimeoutMs,

9+

} from "openclaw/plugin-sdk/number-runtime";

710
811

interface SeenTrackerOptions {

912

/** Maximum number of entries to track (default: 100,000) */

@@ -45,8 +48,8 @@ interface Entry {

4548

*/

4649

export function createSeenTracker(options?: SeenTrackerOptions): SeenTracker {

4750

const maxEntries = resolveIntegerOption(options?.maxEntries, 100_000, { min: 1 });

48-

const ttlMs = options?.ttlMs ?? 60 * 60 * 1000; // 1 hour

49-

const pruneIntervalMs = options?.pruneIntervalMs ?? 10 * 60 * 1000; // 10 minutes

51+

const ttlMs = resolvePositiveTimerTimeoutMs(options?.ttlMs, 60 * 60 * 1000);

52+

const pruneIntervalMs = resolvePositiveTimerTimeoutMs(options?.pruneIntervalMs, 10 * 60 * 1000);

5053
5154

// Main storage

5255

const entries = new Map<string, Entry>();