#Is it expected behavior that polling queries ignore offline mode?

4 messages · Page 1 of 1 (latest)

tidal spindle
#

Hey guys, I am setting up offline mode in my React app but it isn't working as expected. After 2 minutes, the whole local cache is cleared for some reason I haven't figured out, all queries get executed and fail because im in offline mode, which resets the cache somehow. Also, polling queries don't seem to respect offline mode and keep making requests. Is this by desin? Here is my setup:

export const persister = createAsyncStoragePersister({
  storage: window.localStorage,
});

export const queryClient = new QueryClient({
  defaultOptions: {
    queries: {
      staleTime: 60_000, // 1 minute
      networkMode: 'offlineFirst',
      gcTime: 1000 * 60 * 60 * 8, // React Query default behavior is to discard cached data after 5 minutes, we want to keep it for 8 hours since our application is offline first
    },
    mutations: {
      networkMode: 'offlineFirst',
    },
  },
});

<PersistQueryClientProvider
  client={queryClient}
  persistOptions={{
    persister,
  }}
  onSuccess={() => {
    // Resume mutations after initial restore from localStorage was successful
    queryClient.resumePausedMutations();
  }}
>
...
</PersistQueryClientProvider>
dense iron
tidal spindle
#

Hey! Thanks for helping out! I don’t think that the retry option is the issue here. I did some additional investigation and for some reason the online manager which is provided by RQ remains true (meaning the app is online while offline mode is activated in the browser)