Skip to content
Source
Sign inSign up
TanStack/db

fix(db): propagate initial query errors #1751

MergedKyleAMathews(GitHub profile, opens in a new tab)merged 24 commits intomain fromrefs/pull/1751/headmerged by tannerlinsley

Showing 28 changed files with 31 additions and 13 deletions (loading 25).

x
0 of 28 viewed, 28 left
10 additions and 0 deletions.changeset/propagate-initial-query-errors.mdAdded
View file
@@ -0,0 +1,10 @@
+---
+'@tanstack/db': patch
+'@tanstack/electric-db-collection': patch
+'@tanstack/powersync-db-collection': patch
+'@tanstack/query-db-collection': patch
+'@tanstack/rxdb-db-collection': patch
+'@tanstack/trailbase-db-collection': patch
+---
+​
+Propagate initial query sync failures through dependent live queries and readiness promises, including recovery and late subscribers, while preserving a ready cached snapshot on later refetch failures. Let sync adapters pass the original failure to `markError(error)` so readiness promises reject with that cause. Isolate adapter callbacks by sync session, preserve synchronous startup errors, and prevent rejected deduplicated subset requests from creating detached promise rejections.
16 additions and 10 deletionsdocs/guides/collection-options-creator.mdModified
View file
@@ -73,10 +73,11 @@
​
```typescript
const sync: SyncConfig<T>['sync'] = (params) => {
- const { begin, write, commit, markReady, collection } = params
+ const { begin, write, commit, markReady, markError, collection } = params
// 1. Initialize connection to your sync engine
const connection = initializeConnection(config)
+ const initialSyncAbort = new AbortController()
// 2. Set up real-time subscription FIRST (prevents race conditions)