From 1e6faaab58e3e15437fceb33d0aa3c201e6950ba Mon Sep 17 00:00:00 2001 From: Zeltarox Date: Tue, 2 Jun 2026 00:22:14 +0530 Subject: [PATCH] fix(scans): prevent polling memory leak and duplicate API requests --- frontend/src/pages/Scans.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/Scans.tsx b/frontend/src/pages/Scans.tsx index 3e38f3ad..0e93cd90 100644 --- a/frontend/src/pages/Scans.tsx +++ b/frontend/src/pages/Scans.tsx @@ -105,7 +105,9 @@ export default function Scans() { if (document.visibilityState === "hidden") { stopPolling(); } else { - loadTasks(); // immediate refresh when tab comes back + abortRef.current?.abort(); + abortRef.current = new AbortController(); + loadTasks(); startPolling(); } } @@ -114,7 +116,10 @@ export default function Scans() { return () => { stopPolling(); - abortRef.current?.abort(); + if (abortRef.current) { + abortRef.current.abort(); + abortRef.current = null; + } document.removeEventListener("visibilitychange", handleVisibilityChange); }; }, [filter, page]); @@ -709,4 +714,4 @@ export default function Scans() { /> ); -} \ No newline at end of file +}