diff --git a/web_src/js/features/websocket.sharedworker.ts b/web_src/js/features/websocket.sharedworker.ts index 9925ba5bd6..539aa46037 100644 --- a/web_src/js/features/websocket.sharedworker.ts +++ b/web_src/js/features/websocket.sharedworker.ts @@ -1,5 +1,7 @@ // One WebSocket connection per URL, shared across all tabs via SharedWorker. // Messages from the server are JSON objects broadcast to all connected ports. +export {}; // make this a module to avoid global scope conflicts with other sharedworker files + const RECONNECT_DELAY_INITIAL = 50; const RECONNECT_DELAY_MAX = 10000; @@ -116,10 +118,10 @@ const sourcesByPort = new Map(); const source = sourcesByPort.get(port); if (!source) return; const count = source.deregister(port); + sourcesByPort.delete(port); if (count === 0) { source.close(); sourcesByUrl.delete(source.url); - sourcesByPort.delete(port); } } else if (event.data.type === 'status') { const source = sourcesByPort.get(port);