From 06b58e64952cc04b19b698428c6410de5a0114ad Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sat, 5 Oct 2024 16:46:02 -0600 Subject: [PATCH] refactor: close connection ws --- .../application/deployments/show-deployment.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/dokploy/components/dashboard/application/deployments/show-deployment.tsx b/apps/dokploy/components/dashboard/application/deployments/show-deployment.tsx index 19b01e80b..d4b5c5e79 100644 --- a/apps/dokploy/components/dashboard/application/deployments/show-deployment.tsx +++ b/apps/dokploy/components/dashboard/application/deployments/show-deployment.tsx @@ -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(""); } }}