From 6e010378329d10b7b3a6c5a110285b3f70a87cc3 Mon Sep 17 00:00:00 2001 From: Christophe Vila Date: Mon, 27 Jul 2026 09:01:38 +0200 Subject: [PATCH] fix(frontend): stop SyncModal polling once sync has finished It polled /api/sync/status every 1.5s indefinitely even after in_progress became false and the final result was already shown, only stopping on unmount (clicking Close). Skip scheduling the next poll once a fetched status reports the sync is no longer running. Co-Authored-By: Claude Sonnet 5 --- frontend/src/components/SyncModal.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/SyncModal.tsx b/frontend/src/components/SyncModal.tsx index 2926347..d90469b 100644 --- a/frontend/src/components/SyncModal.tsx +++ b/frontend/src/components/SyncModal.tsx @@ -34,9 +34,14 @@ export function SyncModal({ onClose }: { onClose: () => void }) { .then((s) => { setStatus(s); setError(null); + // Once a fetched status reports the sync finished, stop polling -- + // the final result is already shown, and there's nothing new left + // to fetch until the user starts another sync ("Close" unmounts + // this component, which is the only other way polling stops). + if (!stoppedRef.current && s.in_progress) timeout = setTimeout(tick, 1500); }) - .catch((e) => setError(String(e))) - .finally(() => { + .catch((e) => { + setError(String(e)); if (!stoppedRef.current) timeout = setTimeout(tick, 1500); }); };