fix(workspace): add http polling fallback for proxy/firewall environments and exponential ws reconnect backoff
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m2s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m2s
This commit is contained in:
1 parent
e088ef6974
commit
c2ed76c6a4
2 files changed
+65
-9
No files matched your search
@@ -1048,6 +1048,7 @@ let wsListeners: ((msg: WSMessage) => void)[] = [];
|
||||
let wsStatusListeners: ((connected: boolean) => void)[] = [];
|
||||
let isWSConnected = false;
|
||||
let manualDisconnect = false;
|
||||
let wsReconnectDelay = 2000;
|
||||
|
||||
export function buildWebSocketURL(listId?: string): string {
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
@@ -1097,6 +1098,7 @@ export function connectWebSocket(): void {
|
||||
activeGlobalWS = ws;
|
||||
|
||||
ws.onopen = () => {
|
||||
wsReconnectDelay = 2000;
|
||||
notifyStatusChange(true);
|
||||
};
|
||||
|
||||
@@ -1121,9 +1123,11 @@ export function connectWebSocket(): void {
|
||||
notifyStatusChange(false);
|
||||
if (!manualDisconnect && getToken()) {
|
||||
clearTimeout(wsReconnectTimer);
|
||||
const delay = wsReconnectDelay;
|
||||
wsReconnectDelay = Math.min(30000, Math.round(wsReconnectDelay * 1.5));
|
||||
wsReconnectTimer = setTimeout(() => {
|
||||
connectWebSocket();
|
||||
}, 3000);
|
||||
}, delay);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user