From e1732b9bf2b5c3668fa3ccd4d85baf0b156ba973 Mon Sep 17 00:00:00 2001 From: ItzCrazyKns Date: Sun, 14 Jul 2024 12:37:36 +0530 Subject: [PATCH] feat(chat-window): fix WS connection errors --- ui/components/ChatWindow.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/components/ChatWindow.tsx b/ui/components/ChatWindow.tsx index b1a87a2..f2c89a3 100644 --- a/ui/components/ChatWindow.tsx +++ b/ui/components/ChatWindow.tsx @@ -194,8 +194,10 @@ const useSocket = ( } return () => { - ws?.close(); - console.log('[DEBUG] closed'); + if (ws?.readyState === 1) { + ws?.close(); + console.log('[DEBUG] closed'); + } }; }, [ws, url, setIsWSReady, setError]);