fix: [GH-3932]: do not retry API's in case of 4XX status code (#4376)

* fix: [GH-3932]: do not retry API's in case of 400 status code

* feat: do not retry 4XX response status
This commit is contained in:
Vikrant Gupta 2024-03-14 12:07:47 +05:30 committed by GitHub
parent 6b3af78873
commit 1e1624ed4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,7 @@ import 'styles.scss';
import * as Sentry from '@sentry/react';
import AppRoutes from 'AppRoutes';
import { AxiosError } from 'axios';
import { ThemeProvider } from 'hooks/useDarkMode';
import ErrorBoundaryFallback from 'pages/ErrorBoundaryFallback/ErrorBoundaryFallback';
import { createRoot } from 'react-dom/client';
@ -16,6 +17,17 @@ const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
retry(failureCount, error): boolean {
if (
// in case of manually throwing errors please make sure to send error.response.status
error instanceof AxiosError &&
error.response?.status &&
(error.response?.status >= 400 || error.response?.status <= 499)
) {
return false;
}
return failureCount < 2;
},
},
},
});