From f2450cc6e19eb31e722d18cfc38d1e262f8014c4 Mon Sep 17 00:00:00 2001 From: Epid Date: Tue, 24 Mar 2026 13:51:16 +0300 Subject: [PATCH] fix(websocket): remove export{} from sharedworker entry point, rename worker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove `export {}` which caused webpack to tree-shake the entire SharedWorker bundle, resulting in an empty JS file with no connect handler — root cause of WebSocket never opening - Rename SharedWorker instance from 'notification-worker' to 'notification-worker-ws' to force browser to create a fresh worker instance instead of reusing a cached empty one --- web_src/js/features/notification.ts | 2 +- web_src/js/features/websocket.sharedworker.ts | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/web_src/js/features/notification.ts b/web_src/js/features/notification.ts index e31fd5231e..cb025b9fd7 100644 --- a/web_src/js/features/notification.ts +++ b/web_src/js/features/notification.ts @@ -32,7 +32,7 @@ export function initNotificationCount() { if (notificationSettings.EventSourceUpdateTime > 0 && window.SharedWorker) { // Connect via WebSocket SharedWorker (one connection shared across all tabs) const wsUrl = `${window.location.origin}${appSubUrl}/-/ws`.replace(/^http/, 'ws'); - const worker = new SharedWorker(`${window.__webpack_public_path__}js/websocket.sharedworker.js?v=${assetVersionEncoded}`, 'notification-worker'); + const worker = new SharedWorker(`${window.__webpack_public_path__}js/websocket.sharedworker.js?v=${assetVersionEncoded}`, 'notification-worker-ws'); worker.addEventListener('error', (event) => { console.error('worker error', event); }); diff --git a/web_src/js/features/websocket.sharedworker.ts b/web_src/js/features/websocket.sharedworker.ts index f8cc635570..9925ba5bd6 100644 --- a/web_src/js/features/websocket.sharedworker.ts +++ b/web_src/js/features/websocket.sharedworker.ts @@ -1,7 +1,5 @@ // 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;