From 314e68812f7890e84503b1593902e8624e6b6824 Mon Sep 17 00:00:00 2001 From: Jie Li Date: Wed, 12 Nov 2025 22:43:31 +0800 Subject: fix: avoid errors in browser console --- src/api/connections.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/api') diff --git a/src/api/connections.ts b/src/api/connections.ts index fd0901b..772ec4a 100644 --- a/src/api/connections.ts +++ b/src/api/connections.ts @@ -51,11 +51,11 @@ function appendData(s: string) { let o: ConnectionsData; try { o = JSON.parse(s); - o.connections.forEach(conn => { - let m = conn.metadata; + o.connections?.forEach((conn) => { + const m = conn.metadata; if (m.process == null) { if (m.processPath != null) { - m.process = m.processPath.replace(/^.*[/\\](.*)$/, "$1"); + m.process = m.processPath.replace(/^.*[/\\](.*)$/, '$1'); } } }); @@ -86,12 +86,12 @@ export function fetchData( const ws = new WebSocket(url); ws.addEventListener('error', () => { wsState = 3; - subscribers.forEach((s) => s.onClose()); + subscribers.forEach((s) => s.onClose?.()); subscribers.length = 0; }); ws.addEventListener('close', () => { wsState = 3; - subscribers.forEach((s) => s.onClose()); + subscribers.forEach((s) => s.onClose?.()); subscribers.length = 0; }); ws.addEventListener('message', (event) => appendData(event.data)); -- cgit v1.3.1