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

errors are cached and not reset if the component using useQuery is remounted #468

Closed
aaronjensen opened this issue May 8, 2020 · 9 comments
Labels

Comments

@aaronjensen
Copy link
Contributor

Here's an example: https://codesandbox.io/s/elegant-minsky-wwfko?file=/src/index.js

Close the error report window then click "retry". That will remount the Posts component but it will error immediately.

If you uncomment the queryCache.clear() it works.

I would expect that errors are not cached, or that they're cleared when the component is remounted.

My guess is that since the component never officially mounts, there's some edge case here that isn't accounted for, or that this is an intractable problem and I should just always clear the cache on an error (which may very well be a good idea anyway).

@tannerlinsley
Copy link
Collaborator

I’m looking into this

@tannerlinsley
Copy link
Collaborator

🎉 This issue has been resolved in version 1.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@aaronjensen
Copy link
Contributor Author

Thank you for the quick fix.

@jacklj
Copy link
Contributor

jacklj commented Dec 15, 2020

Hello, I'm getting the same issue in v.2.26.4, so I guess there was a regression? Have solved it by clearing the cache as above, but just FYI. Thanks.

@danowens1
Copy link

@tannerlinsley I am also getting the same issue in v.2.26.3. For us the cache clearing is not an optimal solution. Perhaps this issue should be reopened?

@TkDodo
Copy link
Collaborator

TkDodo commented Jan 25, 2021

Feel free to create a new issue / discussion with a codesandbox that shows the issue, preferably on v3.

@jakepeyser
Copy link

For others facing this issue in v2.26.x, it looks like like the bug was also observed in #1412 (comment) and is being addressed in #1781

@tncbbthositg
Copy link

We just ran into the same issue with v3.27.0. If I get a chance to make a code sandbox I will.

This will get us by for now:

  const { reset } = useQueryErrorResetBoundary();
  const queryClient = useQueryClient();

  const resetErrors = () => {
    queryClient.clear();
    reset();
  }

  return (
    <ErrorBoundary onReset={resetErrors} fallbackRender={Fallback}>
      { children }
    </ErrorBoundary>
  );

@TkDodo
Copy link
Collaborator

TkDodo commented Nov 11, 2021

Can you try updating to the latest version please? I remember we had a bug somewhere that was since fixed. Otherwise please open a new issue with a codesandbox reproduction

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

No branches or pull requests

7 participants