From 9f81ce2876efd1dc5c639123acfda4927f2b7d4a Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 20 Jun 2024 06:03:14 -0600 Subject: [PATCH] Only close MSE websocket when it's already open (#12078) --- web/src/components/player/MsePlayer.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/src/components/player/MsePlayer.tsx b/web/src/components/player/MsePlayer.tsx index 33ebbccf2..b699ae49b 100644 --- a/web/src/components/player/MsePlayer.tsx +++ b/web/src/components/player/MsePlayer.tsx @@ -117,12 +117,12 @@ function MSEPlayer({ }, [wsURL]); const onDisconnect = useCallback(() => { - setWsState(WebSocket.CLOSED); - if (wsRef.current) { + if (wsRef.current && wsState == WebSocket.OPEN) { + setWsState(WebSocket.CLOSED); wsRef.current.close(); wsRef.current = null; } - }, []); + }, [wsState]); const onOpen = () => { setWsState(WebSocket.OPEN);