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

query.shouldContinueRetryOnFocus is never reset once a previously failed query succeeds again #528

Closed
hippotastic opened this issue May 28, 2020 · 5 comments · Fixed by #563
Labels
bug Something isn't working good first issue Good for newcomers released

Comments

@hippotastic
Copy link

If one of my queries fails at one point (e.g. because the backend server is unreachable for a while), the following line sets query.shouldContinueRetryOnFocus to true:

https://github.com/tannerlinsley/react-query/blob/66f462c2f9552ca2bbda8ac0fd7595bdb1a4008e/src/queryCache.js#L400

If this flag is true, the query gets refetched every time the window is focused.

However, you seem to have forgotten to delete this flag once the query succeeds again. This causes the query to be refetched on every window focus event, even if it's perfectly fresh and not stale.

@tannerlinsley
Copy link
Collaborator

Hmmm true. Would you like to submit a PR and companion regression test to fix this?

@tannerlinsley tannerlinsley added bug Something isn't working good first issue Good for newcomers labels Jun 2, 2020
@hippotastic
Copy link
Author

I‘m sorry, I don‘t feel like I know enough about the intricacies of how your code and testing works to actually fix this in your code. I just worked around this bug in my code for the time being by getting an instance of the query object from the cache and deleting the flag myself upon a successful fetch. I‘m sure this is way easier to fix for you than it would be for me.

@Avi98
Copy link
Contributor

Avi98 commented Jun 4, 2020

@tannerlinsley @rutzfutz, I could take a look into this.

@tannerlinsley
Copy link
Collaborator

That would be great!

@tannerlinsley
Copy link
Collaborator

🎉 This issue has been resolved in version 1.5.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

3 participants