From 1e1624ed4cb85f01f555289506f5fd85b4dbab87 Mon Sep 17 00:00:00 2001 From: Vikrant Gupta Date: Thu, 14 Mar 2024 12:07:47 +0530 Subject: [PATCH] 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 --- frontend/src/index.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx index b95631c107..570db8c1da 100644 --- a/frontend/src/index.tsx +++ b/frontend/src/index.tsx @@ -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; + }, }, }, });