From 80231c61fd8db9543de997f2554fca4869bd96ec Mon Sep 17 00:00:00 2001 From: litongjava Date: Mon, 20 Jan 2025 19:26:09 -1000 Subject: [PATCH] comment setError(true); when attemptReconnect --- ui/components/ChatWindow.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/components/ChatWindow.tsx b/ui/components/ChatWindow.tsx index b26573f..557b023 100644 --- a/ui/components/ChatWindow.tsx +++ b/ui/components/ChatWindow.tsx @@ -256,12 +256,14 @@ const useSocket = ( }); ws.onerror = () => { + debugger clearTimeout(timeoutId); setIsWSReady(false); toast.error('WebSocket connection error.'); }; ws.onclose = () => { + debugger clearTimeout(timeoutId); setIsWSReady(false); console.debug(new Date(), 'ws:disconnected'); @@ -277,15 +279,17 @@ const useSocket = ( } }; - const attemptReconnect = () => { + const attemptReconnect = async () => { retryCountRef.current += 1; if (retryCountRef.current > MAX_RETRIES) { console.debug(new Date(), 'ws:max_retries'); - setError(true); + //setError(true); + toast.error( 'Unable to connect to server after multiple attempts. Please refresh the page to try again.', ); + await new Promise((resolve) => setTimeout(resolve, 1000)); return; }