Skip to content

Commit 9cf723a

Browse files
committed
next: improved fetch client retry experience on failed requests.
1 parent 380e59e commit 9cf723a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/Exceptionless.Web/ClientApp/src/routes/+layout.svelte

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
import * as Sidebar from '$comp/ui/sidebar';
77
import { Toaster } from '$comp/ui/sonner';
88
import { accessToken } from '$features/auth/index.svelte';
9-
import { type FetchClientContext, setAccessTokenFunc, setBaseUrl, setRequestOptions, useMiddleware } from '@exceptionless/fetchclient';
9+
import { type FetchClientContext, ProblemDetails, setAccessTokenFunc, setBaseUrl, setRequestOptions, useMiddleware } from '@exceptionless/fetchclient';
1010
import { error } from '@sveltejs/kit';
1111
import { QueryClient, QueryClientProvider } from '@tanstack/svelte-query';
1212
import { SvelteQueryDevtools } from '@tanstack/svelte-query-devtools';
13-
import { ModeWatcher } from 'mode-watcher';
1413
1514
import '../app.css';
15+
16+
import { ModeWatcher } from 'mode-watcher';
17+
1618
import { routes } from './routes.svelte';
1719
1820
interface Props {
@@ -63,6 +65,17 @@
6365
const queryClient = new QueryClient({
6466
defaultOptions: {
6567
queries: {
68+
retry: (failureCount, error) => {
69+
if (failureCount > 2) {
70+
return false;
71+
}
72+
73+
if (error instanceof ProblemDetails) {
74+
return !error.status || error.status >= 500;
75+
}
76+
77+
return true;
78+
},
6679
staleTime: 5 * 60 * 1000
6780
}
6881
}

0 commit comments

Comments
 (0)