refactor: close connection ws

This commit is contained in:
Mauricio Siu 2024-10-05 16:46:02 -06:00
parent 24db4006cf
commit 06b58e6495

View File

@ -41,8 +41,10 @@ export const ShowDeployment = ({ logPath, open, onClose, serverId }: Props) => {
};
return () => {
ws.close();
wsRef.current = null;
if (wsRef.current?.readyState === WebSocket.OPEN) {
ws.close();
wsRef.current = null;
}
};
}, [logPath, open]);
@ -62,7 +64,9 @@ export const ShowDeployment = ({ logPath, open, onClose, serverId }: Props) => {
if (!e) setData("");
if (!e && wsRef.current) {
wsRef.current.close(); // Close WebSocket when modal closes
if (wsRef.current.readyState === WebSocket.OPEN) {
wsRef.current.close();
}
setData("");
}
}}