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

Data is not re-validated on error with suspense: true #602

Closed
cinan opened this issue Aug 17, 2020 · 1 comment · Fixed by #2658
Closed

Data is not re-validated on error with suspense: true #602

cinan opened this issue Aug 17, 2020 · 1 comment · Fixed by #2658

Comments

@cinan
Copy link

cinan commented Aug 17, 2020

Bug report

Description / Observed Behavior

Data is not re-validated on a component mount if fetcher throws an error and suspense config is on.

Expected Behavior

Re-validating behaviour should be the same with suspense: true or suspense: false.

Repro Steps / Code Example

https://codesandbox.io/s/vigilant-worker-dr5so?file=/src/App.js

Click on "Toogle fetch component". This will mount the component using swr and throw an error (as expected). Then, double click on the button to remount the component. In Devtools network log I can see network calls are missing when component is re-mounted.

With suspense: false the scenario causes data re-validation on every remount (in Network log I can see a new network call when component is re-mounted.

Additional Context

SWR version: 0.3.0

@promer94
Copy link
Collaborator

If there is an error in the cache,
swr will throw the error immediately in suspense mode
and it will not trigger useEffect hooks in the swr.

So swr wont re-validated with errored cache in suspense mode.

You can find a workaroud in #160

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

Successfully merging a pull request may close this issue.

3 participants