diff options
| author | Larvan2 <[email protected]> | 2025-12-14 14:11:43 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-12-14 14:11:43 +0800 |
| commit | 4abe041d6d21dbd51b3093645573e8590fdcb4bb (patch) | |
| tree | bb8f2d7fccdf671d68917ae0dfddfccdb78e49ba /src/api | |
| parent | 02c5187cc003363a48a0c3dfa9c9101112d198c7 (diff) | |
| parent | 314e68812f7890e84503b1593902e8624e6b6824 (diff) | |
Merge pull request #98 from pupboss/master
fix: avoid errors in browser console
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/connections.ts | 10 |
1 files changed, 5 insertions, 5 deletions
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)); |
