← back to Cncp Failure Collector
tick 7: prune classifier rate-limit Map of entries older than 24h
78ad17a20b938c420b7a1414ffd66c5960c9a88d · 2026-05-11 12:35:46 -0700 · SteveStudio2
Files touched
Diff
commit 78ad17a20b938c420b7a1414ffd66c5960c9a88d
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date: Mon May 11 12:35:46 2026 -0700
tick 7: prune classifier rate-limit Map of entries older than 24h
---
index.js | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/index.js b/index.js
index 8f355dc..296bc7d 100644
--- a/index.js
+++ b/index.js
@@ -26,7 +26,17 @@ const CNCP_URL = process.env.CNCP_URL || 'http://127.0.0.1:3333';
const POLL_INTERVAL_MS = parseInt(process.env.POLL_INTERVAL_MS, 10) || 30_000;
const CLASSIFIER_ENABLED = (process.env.CLASSIFIER_ENABLED || '1') !== '0';
const CLASSIFY_RATE_LIMIT_MS = 5 * 60 * 1000;
+const CLASSIFY_MAP_TTL_MS = 24 * 60 * 60 * 1000; // tick 7: prune entries older than 24h
const lastClassify = new Map(); // processName -> timestamp
+
+function pruneClassifyMap() {
+ const cutoff = Date.now() - CLASSIFY_MAP_TTL_MS;
+ let dropped = 0;
+ for (const [name, ts] of lastClassify.entries()) {
+ if (ts < cutoff) { lastClassify.delete(name); dropped++; }
+ }
+ if (dropped > 0) log(`pruned ${dropped} stale entries from classifier rate-limit map`);
+}
const STATE_FILE = path.join(__dirname, 'state.json');
const ONCE = process.argv.includes('--once');
@@ -264,6 +274,8 @@ let cyclesSinceLastHeartbeat = 0;
const HEARTBEAT_EVERY = 10; // log once every 10 cycles (~5 min at 30s poll) when quiet
async function cycle() {
+ // Prune classifier rate-limit Map — drop entries older than 24h so it doesn't grow unbounded over weeks.
+ pruneClassifyMap();
const state = loadState();
const before = loadCurrentFailuresCount();
try { await scanPm2(state); } catch (e) { log('scanPm2 threw:', e.message); }
← 4292cad tick 6: README pass — covers ticks 2-5b features (classifier
·
back to Cncp Failure Collector
·
shopify cached-page price canary + nightly launchd at 4:17 A 2573de7 →