mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-12 19:03:47 +00:00
refactor: improve request cancellation and timeout handling
This commit is contained in:
committed by
Carlos Valente
parent
cdf02f7c3f
commit
9e8cb1c755
@@ -1,4 +1,5 @@
|
||||
import { QueryClient } from '@tanstack/react-query';
|
||||
import axios from 'axios';
|
||||
import { MILLIS_PER_MINUTE } from 'ontime-utils';
|
||||
|
||||
import { isOntimeCloud } from '../externals';
|
||||
@@ -8,10 +9,15 @@ export const ontimeQueryClient = new QueryClient({
|
||||
queries: {
|
||||
gcTime: 10 * MILLIS_PER_MINUTE,
|
||||
// staleTime: MILLIS_PER_HOUR, //TODO: when all routes have implemented refetch signal from server, we can the assume that the data is not stale until we get the signal
|
||||
networkMode: 'always',
|
||||
networkMode: isOntimeCloud ? 'online' : 'always',
|
||||
refetchOnWindowFocus: false,
|
||||
retry: 5,
|
||||
retryDelay: (attempt) => attempt * 2500,
|
||||
retry: (failureCount, error) => {
|
||||
if (axios.isCancel(error)) {
|
||||
return false;
|
||||
}
|
||||
return failureCount < 5;
|
||||
},
|
||||
retryDelay: (attempt) => Math.min(1000 * 2 ** attempt, 5000),
|
||||
},
|
||||
mutations: {
|
||||
/**
|
||||
@@ -21,6 +27,7 @@ export const ontimeQueryClient = new QueryClient({
|
||||
* - use 'online' for clients that are connected to the cloud
|
||||
*/
|
||||
networkMode: isOntimeCloud ? 'online' : 'always',
|
||||
retry: 0,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user