From e7bdabb667dafcdb103d0b4606ed616f1799e1b4 Mon Sep 17 00:00:00 2001 From: Alex P Date: Thu, 23 Oct 2025 22:48:32 +0300 Subject: [PATCH] fix: suppress expected datachannel closure errors during logout --- ui/src/components/InfoBar.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ui/src/components/InfoBar.tsx b/ui/src/components/InfoBar.tsx index ce444d85..02b917be 100644 --- a/ui/src/components/InfoBar.tsx +++ b/ui/src/components/InfoBar.tsx @@ -31,9 +31,16 @@ export default function InfoBar() { useEffect(() => { if (!rpcDataChannel) return; - rpcDataChannel.onclose = () => console.log("rpcDataChannel has closed"); - rpcDataChannel.onerror = (e: Event) => - console.error(`Error on DataChannel '${rpcDataChannel.label}': ${e}`); + rpcDataChannel.onclose = () => { + if (rpcDataChannel.readyState === "closed") { + console.debug("rpcDataChannel closed"); + } + }; + rpcDataChannel.onerror = (e: Event) => { + if (rpcDataChannel.readyState === "open" || rpcDataChannel.readyState === "connecting") { + console.error(`Error on DataChannel '${rpcDataChannel.label}':`, e); + } + }; }, [rpcDataChannel]); const { keyboardLedState, usbState } = useHidStore();