From 4bc83ebcb522b6813a34dc9c07973273a8382f35 Mon Sep 17 00:00:00 2001 From: lirazyehezkel <61656597+lirazyehezkel@users.noreply.github.com> Date: Mon, 11 Apr 2022 14:21:31 +0300 Subject: [PATCH] Fix WS error when switching from settings to traffic viewer (#985) --- ui-common/src/components/TrafficViewer/TrafficViewer.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui-common/src/components/TrafficViewer/TrafficViewer.tsx b/ui-common/src/components/TrafficViewer/TrafficViewer.tsx index d9391ff6c..af72dd605 100644 --- a/ui-common/src/components/TrafficViewer/TrafficViewer.tsx +++ b/ui-common/src/components/TrafficViewer/TrafficViewer.tsx @@ -201,7 +201,9 @@ export const TrafficViewer: React.FC = ({ useEffect(() => { return () => { - ws.current.close(); + if (ws?.current?.readyState === WebSocket.OPEN) { + ws.current.close(); + } }; }, []);