diff --git a/.claude/scheduled_tasks.lock b/.claude/scheduled_tasks.lock new file mode 100644 index 0000000..e3c4778 --- /dev/null +++ b/.claude/scheduled_tasks.lock @@ -0,0 +1 @@ +{"sessionId":"7dcf4561-975e-4864-a297-1814a6ac9aea","pid":12187,"acquiredAt":1776060371368} \ No newline at end of file diff --git a/src/features/scan/ScanPage.tsx b/src/features/scan/ScanPage.tsx index 27e79a4..7d132ef 100644 --- a/src/features/scan/ScanPage.tsx +++ b/src/features/scan/ScanPage.tsx @@ -49,6 +49,16 @@ export function ScanPage() { const bufRef = useRef(freshBuf()); const timerRef = useRef | null>(null); + // Stop the periodic flush interval. Inlined into flush() to avoid a + // circular useCallback dep (flush → stopFlushing → flush) that tripped + // TDZ in prod builds: "can't access lexical declaration 'o' before initialization". + const clearFlushTimer = () => { + if (timerRef.current) { + clearInterval(timerRef.current); + timerRef.current = null; + } + }; + // Flush buffered SSE data to React state const flush = useCallback(() => { const b = bufRef.current; @@ -72,16 +82,16 @@ export function ScanPage() { setStatusLabel(`Scan complete — ${d.scanned ?? "?"} items, ${d.errors ?? 0} errors`); setScanComplete(true); setStatus((prev) => (prev ? { ...prev, running: false } : prev)); - stopFlushing(); + clearFlushTimer(); } if (b.lost) { b.lost = false; setStatusLabel("Scan connection lost — refresh to see current status"); setStatus((prev) => (prev ? { ...prev, running: false } : prev)); - stopFlushing(); + clearFlushTimer(); } - }, [stopFlushing]); + }, []); const startFlushing = useCallback(() => { if (timerRef.current) return; @@ -90,8 +100,7 @@ export function ScanPage() { const stopFlushing = useCallback(() => { if (!timerRef.current) return; - clearInterval(timerRef.current); - timerRef.current = null; + clearFlushTimer(); flush(); // final flush }, [flush]);