Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions .changeset/fix-query-collection-remount-cache.md

This file was deleted.

4 changes: 2 additions & 2 deletions examples/react/offline-transactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"dependencies": {
"@tanstack/offline-transactions": ">=1.0.0",
"@tanstack/query-db-collection": ">=1.0.3",
"@tanstack/react-db": ">=0.1.48",
"@tanstack/query-db-collection": ">=1.0.4",
"@tanstack/react-db": ">=0.1.49",
"@tanstack/react-query": "^5.90.10",
"@tanstack/react-router": "^1.136.8",
"@tanstack/react-router-devtools": "^1.136.8",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/projects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"dependencies": {
"@tailwindcss/vite": "^4.1.17",
"@tanstack/query-core": "^5.90.10",
"@tanstack/query-db-collection": ">=1.0.3",
"@tanstack/react-db": ">=0.1.48",
"@tanstack/query-db-collection": ">=1.0.4",
"@tanstack/react-db": ">=0.1.49",
"@tanstack/react-router": "^1.136.8",
"@tanstack/react-router-devtools": "^1.136.8",
"@tanstack/react-router-with-query": "^1.130.17",
Expand Down
7 changes: 7 additions & 0 deletions packages/angular-db/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tanstack/angular-db

## 0.1.31

### Patch Changes

- Updated dependencies [[`077fc1a`](https://github.com/TanStack/db/commit/077fc1a418ca090d7533115888c09f3f609e36b2)]:
- @tanstack/db@0.5.5

## 0.1.30

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/angular-db/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tanstack/angular-db",
"description": "Angular integration for @tanstack/db",
"version": "0.1.30",
"version": "0.1.31",
"author": "Ethan McDaniel",
"license": "MIT",
"repository": {
Expand Down
9 changes: 9 additions & 0 deletions packages/db-collection-e2e/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @tanstack/db-collection-e2e

## 0.0.7

### Patch Changes

- Updated dependencies [[`077fc1a`](https://github.com/TanStack/db/commit/077fc1a418ca090d7533115888c09f3f609e36b2)]:
- @tanstack/query-db-collection@1.0.4
- @tanstack/db@0.5.5
- @tanstack/electric-db-collection@0.2.5

## 0.0.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/db-collection-e2e/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tanstack/db-collection-e2e",
"version": "0.0.6",
"version": "0.0.7",
"private": true,
"description": "End-to-end test suite for TanStack DB collections",
"type": "module",
Expand Down
25 changes: 25 additions & 0 deletions packages/db/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# @tanstack/db

## 0.5.5

### Patch Changes

- Fix data loss on component remount by implementing reference counting for QueryObserver lifecycle ([#870](https://github.com/TanStack/db/pull/870))

**What changed vs main:**

Previously, when live query subscriptions unsubscribed, there was no tracking of which rows were still needed by other active queries. This caused data loss during remounts.

This PR adds reference counting infrastructure to properly manage QueryObserver lifecycle:
1. Pass same predicates to `unloadSubset` that were passed to `loadSubset`
2. Use them to compute the queryKey (via `generateQueryKeyFromOptions`)
3. Use existing machinery (`queryToRows` map) to find rows that query loaded
4. Decrement the ref count
5. GC rows where count reaches 0 (no longer referenced by any active query)

**Impact:**
- Navigation back to previously loaded pages shows cached data immediately
- No unnecessary refetches during quick remounts (< gcTime)
- Multiple live queries with identical predicates correctly share QueryObservers
- Proper row-level cleanup when last subscriber leaves
- TanStack Query's cache lifecycle (gcTime) is fully respected
- No data leakage from in-flight requests when unsubscribing

## 0.5.4

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/db/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tanstack/db",
"description": "A reactive client store for building super fast apps on sync",
"version": "0.5.4",
"version": "0.5.5",
"dependencies": {
"@standard-schema/spec": "^1.0.0",
"@tanstack/db-ivm": "workspace:*",
Expand Down
7 changes: 7 additions & 0 deletions packages/electric-db-collection/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tanstack/electric-db-collection

## 0.2.5

### Patch Changes

- Updated dependencies [[`077fc1a`](https://github.com/TanStack/db/commit/077fc1a418ca090d7533115888c09f3f609e36b2)]:
- @tanstack/db@0.5.5

## 0.2.4

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/electric-db-collection/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tanstack/electric-db-collection",
"description": "ElectricSQL collection for TanStack DB",
"version": "0.2.4",
"version": "0.2.5",
"dependencies": {
"@electric-sql/client": "^1.1.5",
"@standard-schema/spec": "^1.0.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/powersync-db-collection/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tanstack/powersync-db-collection

## 0.1.9

### Patch Changes

- Updated dependencies [[`077fc1a`](https://github.com/TanStack/db/commit/077fc1a418ca090d7533115888c09f3f609e36b2)]:
- @tanstack/db@0.5.5

## 0.1.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/powersync-db-collection/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tanstack/powersync-db-collection",
"description": "PowerSync collection for TanStack DB",
"version": "0.1.8",
"version": "0.1.9",
"dependencies": {
"@standard-schema/spec": "^1.0.0",
"@tanstack/db": "workspace:*",
Expand Down
28 changes: 28 additions & 0 deletions packages/query-db-collection/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# @tanstack/query-db-collection

## 1.0.4

### Patch Changes

- Fix data loss on component remount by implementing reference counting for QueryObserver lifecycle ([#870](https://github.com/TanStack/db/pull/870))

**What changed vs main:**

Previously, when live query subscriptions unsubscribed, there was no tracking of which rows were still needed by other active queries. This caused data loss during remounts.

This PR adds reference counting infrastructure to properly manage QueryObserver lifecycle:
1. Pass same predicates to `unloadSubset` that were passed to `loadSubset`
2. Use them to compute the queryKey (via `generateQueryKeyFromOptions`)
3. Use existing machinery (`queryToRows` map) to find rows that query loaded
4. Decrement the ref count
5. GC rows where count reaches 0 (no longer referenced by any active query)

**Impact:**
- Navigation back to previously loaded pages shows cached data immediately
- No unnecessary refetches during quick remounts (< gcTime)
- Multiple live queries with identical predicates correctly share QueryObservers
- Proper row-level cleanup when last subscriber leaves
- TanStack Query's cache lifecycle (gcTime) is fully respected
- No data leakage from in-flight requests when unsubscribing

- Updated dependencies [[`077fc1a`](https://github.com/TanStack/db/commit/077fc1a418ca090d7533115888c09f3f609e36b2)]:
- @tanstack/db@0.5.5

## 1.0.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/query-db-collection/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tanstack/query-db-collection",
"description": "TanStack Query collection for TanStack DB",
"version": "1.0.3",
"version": "1.0.4",
"dependencies": {
"@standard-schema/spec": "^1.0.0"
},
Expand Down
7 changes: 7 additions & 0 deletions packages/react-db/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tanstack/react-db

## 0.1.49

### Patch Changes

- Updated dependencies [[`077fc1a`](https://github.com/TanStack/db/commit/077fc1a418ca090d7533115888c09f3f609e36b2)]:
- @tanstack/db@0.5.5

## 0.1.48

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react-db/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tanstack/react-db",
"description": "React integration for @tanstack/db",
"version": "0.1.48",
"version": "0.1.49",
"author": "Kyle Mathews",
"license": "MIT",
"repository": {
Expand Down
7 changes: 7 additions & 0 deletions packages/rxdb-db-collection/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tanstack/rxdb-db-collection

## 0.1.37

### Patch Changes

- Updated dependencies [[`077fc1a`](https://github.com/TanStack/db/commit/077fc1a418ca090d7533115888c09f3f609e36b2)]:
- @tanstack/db@0.5.5

## 0.1.36

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/rxdb-db-collection/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tanstack/rxdb-db-collection",
"description": "RxDB collection for TanStack DB",
"version": "0.1.36",
"version": "0.1.37",
"dependencies": {
"rxdb": "16.20.0",
"@standard-schema/spec": "^1.0.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/solid-db/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tanstack/react-db

## 0.1.48

### Patch Changes

- Updated dependencies [[`077fc1a`](https://github.com/TanStack/db/commit/077fc1a418ca090d7533115888c09f3f609e36b2)]:
- @tanstack/db@0.5.5

## 0.1.47

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/solid-db/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tanstack/solid-db",
"description": "Solid integration for @tanstack/db",
"version": "0.1.47",
"version": "0.1.48",
"author": "Kyle Mathews",
"license": "MIT",
"repository": {
Expand Down
7 changes: 7 additions & 0 deletions packages/svelte-db/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tanstack/svelte-db

## 0.1.48

### Patch Changes

- Updated dependencies [[`077fc1a`](https://github.com/TanStack/db/commit/077fc1a418ca090d7533115888c09f3f609e36b2)]:
- @tanstack/db@0.5.5

## 0.1.47

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-db/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tanstack/svelte-db",
"description": "Svelte integration for @tanstack/db",
"version": "0.1.47",
"version": "0.1.48",
"dependencies": {
"@tanstack/db": "workspace:*"
},
Expand Down
7 changes: 7 additions & 0 deletions packages/trailbase-db-collection/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tanstack/trailbase-db-collection

## 0.1.49

### Patch Changes

- Updated dependencies [[`077fc1a`](https://github.com/TanStack/db/commit/077fc1a418ca090d7533115888c09f3f609e36b2)]:
- @tanstack/db@0.5.5

## 0.1.48

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/trailbase-db-collection/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tanstack/trailbase-db-collection",
"description": "TrailBase collection for TanStack DB",
"version": "0.1.48",
"version": "0.1.49",
"dependencies": {
"@standard-schema/spec": "^1.0.0",
"@tanstack/db": "workspace:*",
Expand Down
7 changes: 7 additions & 0 deletions packages/vue-db/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tanstack/vue-db

## 0.0.81

### Patch Changes

- Updated dependencies [[`077fc1a`](https://github.com/TanStack/db/commit/077fc1a418ca090d7533115888c09f3f609e36b2)]:
- @tanstack/db@0.5.5

## 0.0.80

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-db/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tanstack/vue-db",
"description": "Vue integration for @tanstack/db",
"version": "0.0.80",
"version": "0.0.81",
"author": "Kyle Mathews",
"license": "MIT",
"repository": {
Expand Down