[object Object]

← back to Ken

Ken: fix restartIntervals crash — it referenced boot-scoped runScanSafe/runSweepSafe (ReferenceError crashed the process whenever POST /api/scan-config ran). Call module-level autonomousScan/redditIntelligenceLoop directly with catch guards. Boot path unchanged.

bf37e331e39d326d197d037f47e4de1b89ebf06e · 2026-08-03 09:35:23 -0700 · steve@designerwallcoverings.com

Files touched

Diff

commit bf37e331e39d326d197d037f47e4de1b89ebf06e
Author: steve@designerwallcoverings.com <steve@designerwallcoverings.com>
Date:   Mon Aug 3 09:35:23 2026 -0700

    Ken: fix restartIntervals crash — it referenced boot-scoped runScanSafe/runSweepSafe (ReferenceError crashed the process whenever POST /api/scan-config ran). Call module-level autonomousScan/redditIntelligenceLoop directly with catch guards. Boot path unchanged.
---
 kalshi-dash/server.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kalshi-dash/server.js b/kalshi-dash/server.js
index b81deb2..77d5828 100644
--- a/kalshi-dash/server.js
+++ b/kalshi-dash/server.js
@@ -5111,8 +5111,12 @@ function restartIntervals() {
   if (signalIntervalId) clearInterval(signalIntervalId);
   if (resolveIntervalId) clearInterval(resolveIntervalId);
 
-  scanIntervalId = setInterval(() => runScanSafe(autonomousScan), SCAN_INTERVAL_MS);
-  redditIntervalId = setInterval(() => runSweepSafe('Reddit', redditIntelligenceLoop), REDDIT_INTERVAL_MS);
+  // FIX 2026-08-03: runScanSafe/runSweepSafe are nested in the boot scope and are NOT
+  // visible here, so referencing them crashed the process (ReferenceError: runScanSafe
+  // is not defined) whenever restartIntervals ran — e.g. via POST /api/scan-config.
+  // Call the module-level scan/sweep fns directly with a catch guard instead.
+  scanIntervalId = setInterval(() => { autonomousScan().catch(e => console.error('[Ken] Scan error:', e.message)); }, SCAN_INTERVAL_MS);
+  redditIntervalId = setInterval(() => { redditIntelligenceLoop().catch(e => console.error('[Ken] Reddit sweep error:', e.message)); }, REDDIT_INTERVAL_MS);
   signalIntervalId = setInterval(async () => {
     if (cachedActiveMarkets.length > 0) {
       try { await signalPipeline(cachedActiveMarkets); } catch (e) { console.log(`[Ken] Fast pipeline error: ${e.message}`); }

← 9507bcf Ken: config-cache coherence — autoTrader refreshes enabled g  ·  back to Ken  ·  Ken: saveTradeConfig read-merges DB enabled gate (root-cause d1ce301 →