Skip to content
Source
Sign inSign up
TanStack/query

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

Send to my agent
Closedhippotastic(GitHub profile, opens in a new tab) opened this issue 5 comments

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.

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

  2. tannerlinsley added labelsbug

  3. tannerlinsley added labelsgood first issue

  4. 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.

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

  6. That would be great!

  7. tannerlinsley closed this

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

    The release is available on:

    Your semantic-release bot :package::rocket:

  9. tannerlinsley added labelsreleased

Sign in to join this conversation.