Revert commit and don't evict query keys from cache - #905
Conversation
|
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: -141 B (-0.16%) Total Size: 86.3 kB
ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 3.34 kB ℹ️ View Unchanged
|
|
Closing this PR as the e2e tests revealed that we can have loadSubset calls with the same options leading to duplicate subscribers so we need to ref count them which is essentially what #870 did. |
When a live query is GCed its subscription is unsubscribed and the Query collection then immediately tells tanstack/query to remove the corresponding query keys. However, this means that the query data is immediately GCed. So if a user quickly browses to another page and comes back the data has to load again because it was immediately GCed on onmount. We should not evict it immediately but simply delete the tanstack/query observer such that tanstack/query will GC the data after the cache time has elapsed.
#870 fixes this but it also introduces a couple of other changes that aren't needed. I reverted that commit.
I added a unit test that reproduces the problem: https://github.com/TanStack/db/actions/runs/19669831433/job/56335642878?pr=905