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

onErrorRetry not triggered after tab blur+focus with useSWRImmutable #2543

Closed
BertrandBordage opened this issue Apr 4, 2023 · 2 comments · Fixed by #2848
Closed

onErrorRetry not triggered after tab blur+focus with useSWRImmutable #2543

BertrandBordage opened this issue Apr 4, 2023 · 2 comments · Fixed by #2848
Labels
bug Something isn't working

Comments

@BertrandBordage
Copy link

Bug report

Description / Observed Behavior

useSWRImmutable stops retrying errored requests if you switch to a different browser tab then go back to the application.
This happens using the default onErrorRetry as well as a custom one.

Expected Behavior

Like useSWR, useSWRImmutable should keep retrying until the request ends successfully.
Of course, once the first successful request is finished useSWRImmutable should never run again, unlike useSWR.

Repro Steps / Code Example

https://codesandbox.io/s/useswrimmutable-onerrorretry-bug-89n0de

Additional Context

SWR version 2.1.2

@promer94 promer94 added the bug Something isn't working label Apr 9, 2023
@milhamm
Copy link

milhamm commented Jul 1, 2023

This also happens using useSWR when revalidateOnFocus is set to false

@Shubhdeep12
Copy link

Shubhdeep12 commented Oct 29, 2023

I encountered this.

I tried to debug it.

When it comes to softrevalidate on focus and reconnecting. we check these conditions

on focus - if ( getConfig().revalidateOnFocus && now > nextFocusRevalidatedAt && isActive() )
and on reconnect - if ( getConfig().revalidateOnReconnect && isActive() )

But, in the case of swrimmutable we don't want to revalidate the data but what if API fails and we have to run errorOnRetry. then we have to revalidate and there comes executing softRevalidate.

I think we should also add a condition checking getConfig().shouldRetryOnError it should be either the revalidate flag
|| shouldretryonerror
any thoughts @promer94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants