mirror of https://github.com/buster-so/buster.git
web(memory): ensure WebSocket and message queues are disposed on unmount to prevent growth over time
Co-Authored-By: nate@buster.so <nate@buster.so>
This commit is contained in:
parent
34515032ee
commit
1bd1c9453e
|
@ -221,6 +221,16 @@ const useWebSocket = ({ url, checkTokenValidity, canConnect, onMessage }: WebSoc
|
||||||
});
|
});
|
||||||
|
|
||||||
useWindowFocus(() => {
|
useWindowFocus(() => {
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
try {
|
||||||
|
ws.current?.close();
|
||||||
|
} catch {}
|
||||||
|
messageQueue.current = [];
|
||||||
|
sendQueue.current = [];
|
||||||
|
processing.current = false;
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
handleVisibilityChange();
|
handleVisibilityChange();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue