fix: stop WS reconnect loop on auth rejection (code 1008)

When the server closes WebSocket with 1008 (invalid token), the client
no longer retries — eliminates log spam from stale sessions.
This commit is contained in:
Fringg
2026-02-17 10:36:38 +03:00
parent 062976180c
commit 2efce0eb03

View File

@@ -116,6 +116,12 @@ export function WebSocketProvider({ children }: { children: React.ReactNode }) {
pingIntervalRef.current = null;
}
// Don't reconnect on auth failures (1008 = Policy Violation / invalid token)
if (event.code === 1008) {
if (isDev) console.log('[WS] Auth rejected, not reconnecting');
return;
}
// Attempt to reconnect if not closed intentionally
if (event.code !== 1000 && reconnectAttemptsRef.current < maxReconnectAttempts) {
const delay = Math.min(