mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-21 08:50:51 +02:00
fix(websocket): remove export{} from sharedworker entry point, rename worker
- 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
This commit is contained in:
parent
1537d8f74a
commit
f2450cc6e1
@ -32,7 +32,7 @@ export function initNotificationCount() {
|
|||||||
if (notificationSettings.EventSourceUpdateTime > 0 && window.SharedWorker) {
|
if (notificationSettings.EventSourceUpdateTime > 0 && window.SharedWorker) {
|
||||||
// Connect via WebSocket SharedWorker (one connection shared across all tabs)
|
// Connect via WebSocket SharedWorker (one connection shared across all tabs)
|
||||||
const wsUrl = `${window.location.origin}${appSubUrl}/-/ws`.replace(/^http/, 'ws');
|
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) => {
|
worker.addEventListener('error', (event) => {
|
||||||
console.error('worker error', event);
|
console.error('worker error', event);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
// One WebSocket connection per URL, shared across all tabs via SharedWorker.
|
// One WebSocket connection per URL, shared across all tabs via SharedWorker.
|
||||||
// Messages from the server are JSON objects broadcast to all connected ports.
|
// 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_INITIAL = 50;
|
||||||
const RECONNECT_DELAY_MAX = 10000;
|
const RECONNECT_DELAY_MAX = 10000;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user