Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RefreshInterval Config Not Respected After Errors #830

Closed
samsouder opened this issue Dec 18, 2020 · 3 comments
Closed

RefreshInterval Config Not Respected After Errors #830

samsouder opened this issue Dec 18, 2020 · 3 comments

Comments

@samsouder
Copy link

I have set up the useSWR hook in a Next.js application that is intended to continually refresh some API data. I was noticing that after some errors (502s technically, but any error is fine to reproduce) the refreshInterval: 2000 I had set wasn't being used anymore and only manually re-focusing the page would cause a revalidation/refresh of the data. Even then, the refreshInterval didn't not pick back up after the error went away.

I have also tried manually specifying an onErrorRetry method which did not change the outcome:

onErrorRetry: (error, key, config, revalidate, { retryCount }) => {
    // Retry after 5 seconds.
    setTimeout(() => revalidate({ retryCount: retryCount + 1 }), 5000)
}

Any guidance here would be much appreciated.

Expected Behavior

I was expecting the refreshInterval to be respected after the error retry logic was able to get a positive result again.

Repro Steps / Code Example

https://codesandbox.io/s/gifted-gagarin-od5ut

Additional Context

SWR version 0.3.9

@samsouder
Copy link
Author

In my example sandbox application you can see that the request count rises to 4, hits the 5xx error on request 5, then will succeed to pull another single request but stops thereafter.

@samsouder
Copy link
Author

I might also note why I care about this scenario (continual refresh regardless of errors, interaction, etc) specifically is because this is a site loaded on a remote display that isn't interacted with.

@hsddu
Copy link

hsddu commented Jun 24, 2024

how do you solve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants