From 1f9fa08002645cbb1b32177a772819235d08a600 Mon Sep 17 00:00:00 2001 From: ashim-hq Date: Tue, 21 Apr 2026 09:24:10 +0800 Subject: [PATCH] fix: prevent polling leak when online event fires from connected state Guard startPolling in handleOnline to only fire when transitioning from offline state. Previously, a spurious browser online event while already connected would start a polling interval that never gets cleared. --- apps/web/src/hooks/use-connection-monitor.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/web/src/hooks/use-connection-monitor.ts b/apps/web/src/hooks/use-connection-monitor.ts index 519caa90..b4fb0177 100644 --- a/apps/web/src/hooks/use-connection-monitor.ts +++ b/apps/web/src/hooks/use-connection-monitor.ts @@ -7,8 +7,11 @@ export function useConnectionMonitor() { const handleOffline = () => store.getState().setOffline(); const handleOnline = () => { + const prev = store.getState().status; store.getState().setOnline(); - store.getState().startPolling(); + if (prev === "offline") { + store.getState().startPolling(); + } }; window.addEventListener("offline", handleOffline);