React-query: query.shouldContinueRetryOnFocus is never reset once a previously failed query succeeds again

Created on 29 May 2020  路  5Comments  路  Source: tannerlinsley/react-query

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.

bug good first issue released

Most helpful comment

That would be great!

All 5 comments

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

I鈥榤 sorry, I don鈥榯 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鈥榤 sure this is way easier to fix for you than it would be for me.

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

That would be great!

:tada: This issue has been resolved in version 1.5.7 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AngusMorton picture AngusMorton  路  4Comments

ivowork picture ivowork  路  5Comments

bgazzera picture bgazzera  路  4Comments

lgenzelis picture lgenzelis  路  4Comments

jackmellis picture jackmellis  路  5Comments