From 1bd1c9453e6e3a8d509ebe21760231fe6338cf89 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 8 Aug 2025 05:49:40 +0000 Subject: [PATCH] web(memory): ensure WebSocket and message queues are disposed on unmount to prevent growth over time Co-Authored-By: nate@buster.so --- apps/web/src/hooks/useWebSocket/useWebSocket.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/web/src/hooks/useWebSocket/useWebSocket.ts b/apps/web/src/hooks/useWebSocket/useWebSocket.ts index d554c2479..dec899155 100644 --- a/apps/web/src/hooks/useWebSocket/useWebSocket.ts +++ b/apps/web/src/hooks/useWebSocket/useWebSocket.ts @@ -221,6 +221,16 @@ const useWebSocket = ({ url, checkTokenValidity, canConnect, onMessage }: WebSoc }); useWindowFocus(() => { + useEffect(() => { + return () => { + try { + ws.current?.close(); + } catch {} + messageQueue.current = []; + sendQueue.current = []; + processing.current = false; + }; + }, []); handleVisibilityChange(); });