SvelteStack / svelte-query

Performant and powerful remote data synchronization for Svelte
https://sveltequery.vercel.app
MIT License
814 stars 31 forks source link

Query still runs on re:focus even if failed 6 retries #42

Closed saturnonearth closed 2 years ago

saturnonearth commented 3 years ago

If a query fails and retries 6 times, it stops, but then re-starts on window re-focus.

SomaticIT commented 2 years ago

This is an expected behavior, queries are also re-started if you navigate again on this page.

If you want to avoid some errors to be retried (eg: 404, 403, etc.), you can use the retry option:

// on a specific query
const query = useQuery("users", loadUsers, {
  retry: (failureCount, err) => failureCount < 3 && (err.status !== 403 || err.status !== 404),
});

// or globally
const client = new QueryClient({
  defaultOptions: {
    queries: {
      retry: (failureCount, err) => failureCount < 3 && (err.status !== 403 || err.status !== 404),
    },
  },
});