summaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorJie Li <[email protected]>2025-11-12 22:43:31 +0800
committerJie Li <[email protected]>2025-11-12 22:43:31 +0800
commit314e68812f7890e84503b1593902e8624e6b6824 (patch)
tree50fefb55f54833bf9b91f11c184932f6c07c7115 /src/api
parent3959e45747aabe9ec3dea011f66851d8c219a5fb (diff)
fix: avoid errors in browser console
Diffstat (limited to 'src/api')
-rw-r--r--src/api/connections.ts10
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));