mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-13 05:15:01 +02:00
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
This commit is contained in:
parent
bf564d3f05
commit
7e8f5a89aa
@ -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<MessagePort, WsSource>();
|
||||
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user