-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Labels
Description
Describe the bug
Queries that should be garbage collected because the cacheTime
has elapsed are kept in memory forever if the query was fetching when the last observer was removed.
To Reproduce
https://codesandbox.io/s/youthful-neumann-rh8t6?file=/src/index.js
note:
cacheTime
is 2 seconds- the query takes 5 seconds to fetch
- it's best to wait until the query has loaded once, then trigger a refetch via window focus and click the button which will unmount the query while the fetch is happening.
Expected behavior
queries to be garbage collected correctly
Additional context
I think the problem is that optionalRemove
, once it determines that it has no observers but doesn't remove the query because it's still fetching doesn't restart the timer: