data-client: After cache is cleared, some resources are never re-fetched

React version (e.g., 16.8.5) 16.13.1

Concurrent mode yes/no no

Rest Hooks version (e.g., 4.5.9) 4.5.9

Describe the bug After resetting the cache (using useResetter()), some resources get stuck in a state where they are never refetched, causing any component that depends on them (using useResource()) to be stuck in suspense mode.

To Reproduce Steps to reproduce the behavior:

  1. Attempt to load a slow-loading resource using useResource().
  2. While this resource is loading, reset the cache using useResetter().
  3. Attempt to load the same resource again.
  4. Observe the component stuck in suspense.

Expected behavior In step 3, the resource should be re-fetched.

Additional context I’m guessing it has to do with this line. The promise is indeed already present in this.fetched, but it’s rejected: context

So I’m assuming something in the network manager cleanup should be removing this, or the line referenced above should be checking to see if the promise is still pending, not just if it’s present.

Hopefully this is enough info to track down the bug (or tell me what I’m doing wrong), but if not I can try to create a minimal example to reproduce this.

Thanks for an awesome library!

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15

Most upvoted comments

Regarding types - I have an explanation going up on docs site soon https://github.com/coinbase/rest-hooks/pull/486/files#diff-0ab0428a5fb5dbcd85cd942fb836a6f6ce5ff7b511a2fddd1e76230f55f3b72a

Use cases: I was under the impression there were two use cases:

  • Logout - where it should def reset cache
  • Page becomes visible - where we want to get fresh data