diff --git a/web/src/api/WsProvider.tsx b/web/src/api/WsProvider.tsx index 4e4f72490b..d00772f9d5 100644 --- a/web/src/api/WsProvider.tsx +++ b/web/src/api/WsProvider.tsx @@ -56,7 +56,14 @@ export function WsProvider({ children }: { children: ReactNode }) { if (reconnectTimer.current) { clearTimeout(reconnectTimer.current); } - wsRef.current?.close(); + const ws = wsRef.current; + if (ws) { + ws.onopen = null; + ws.onmessage = null; + ws.onclose = null; + ws.onerror = null; + ws.close(); + } resetWsStore(); }; }, [wsUrl]);