Skip to content

Commit

Permalink
API queries: fail fast and retry only for network errors and HTTP 502…
Browse files Browse the repository at this point in the history
…/503/504s (#10837)
  • Loading branch information
rithviknishad authored Feb 27, 2025
1 parent b40c931 commit 6c95ea4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,23 @@ import AuthUserProvider from "@/Providers/AuthUserProvider";
import HistoryAPIProvider from "@/Providers/HistoryAPIProvider";
import Routers from "@/Routers";
import { handleHttpError } from "@/Utils/request/errorHandler";
import { HTTPError } from "@/Utils/request/types";

import { PubSubProvider } from "./Utils/pubsubContext";

const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: 2,
retry: (failureCount, error) => {
// Only retry network errors or server errors (502, 503, 504) up to 3 times
if (
error.message === "Network Error" ||
(error instanceof HTTPError && [502, 503, 504].includes(error.status))
) {
return failureCount < 3;
}
return false;
},
refetchOnWindowFocus: false,
},
},
Expand Down

0 comments on commit 6c95ea4

Please sign in to comment.