-
-
Notifications
You must be signed in to change notification settings - Fork 40.6k
Closed
Description
Summary
The groupHistories Map grows unbounded as new groups/topics are encountered. Keys are never deleted, only values are cleared.
Affected Files
src/telegram/bot.ts→dist/telegram/bot.js:152src/signal/monitor.ts→dist/signal/monitor.jssrc/web/auto-reply/monitor.ts→dist/web/auto-reply/monitor.jssrc/imessage/monitor/monitor-provider.ts→dist/imessage/monitor/monitor-provider.js
Problem
const groupHistories = new Map(); // Never cleaned upAs users interact with more groups/topics over time, the Map grows. Growth is O(unique groups), not O(messages), so it's slow but unbounded.
Impact
- Long-running instances accumulate memory
- Severity: LOW (slow growth, only affects long uptimes with many groups)
Suggested Fix
Option 1: Use a TTL-based Map with automatic eviction
import { createTTLMap } from '../infra/ttl-map.js';
const groupHistories = createTTLMap({ maxAge: 24 * 60 * 60 * 1000 }); // 24h TTLOption 2: Add periodic LRU eviction for oldest entries
Verification
Confirmed by code analysis with Codex CLI.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels