test sse fixes
This commit is contained in:
@@ -19,6 +19,7 @@ const eventHandlers: Record<string, EventHandler> = {
|
||||
logger.info("New Connection");
|
||||
},
|
||||
"ping": () => {},
|
||||
"heartbeat": () => {},
|
||||
"match": (event, queryClient) => {
|
||||
queryClient.invalidateQueries(tournamentQueries.details(event.tournamentId))
|
||||
queryClient.invalidateQueries(tournamentQueries.current())
|
||||
@@ -73,15 +74,15 @@ export function useServerEvents() {
|
||||
logger.error("SSE connection error", error);
|
||||
eventSource.close();
|
||||
|
||||
if (shouldConnectRef.current && retryCountRef.current < 5) {
|
||||
if (shouldConnectRef.current && retryCountRef.current < 10) {
|
||||
retryCountRef.current += 1;
|
||||
const delay = Math.min(
|
||||
1000 * Math.pow(2, retryCountRef.current - 1),
|
||||
30000
|
||||
1000 * Math.pow(1.5, retryCountRef.current - 1),
|
||||
15000
|
||||
);
|
||||
|
||||
logger.info(
|
||||
`SSE reconnection attempt ${retryCountRef.current}/5 in ${delay}ms`
|
||||
`SSE reconnection attempt ${retryCountRef.current}/10 in ${delay}ms`
|
||||
);
|
||||
|
||||
timeoutRef.current = setTimeout(() => {
|
||||
@@ -89,7 +90,7 @@ export function useServerEvents() {
|
||||
connectEventSource();
|
||||
}
|
||||
}, delay);
|
||||
} else if (retryCountRef.current >= 5) {
|
||||
} else if (retryCountRef.current >= 10) {
|
||||
logger.error("SSE max reconnection attempts reached");
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user