From 7e8f5a89aa0042f37d9dd3aa93685848698f9b68 Mon Sep 17 00:00:00 2001 From: Epid Date: Tue, 24 Mar 2026 22:25:26 +0300 Subject: [PATCH] fix(websocket): declare sharedworker as ES module and fix port cleanup - Add export{} to declare websocket.sharedworker.ts as an ES module, preventing TypeScript TS2451 redeclaration errors caused by global scope conflicts with eventsource.sharedworker.ts - Always delete port from sourcesByPort on close regardless of remaining subscriber count, preventing MessagePort keys from leaking in the Map --- web_src/js/features/websocket.sharedworker.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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);