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]);