@tanstack/trailbase-db-collection#
1.0.0-rc.1#
Major Changes#
Release the first 1.0 candidate. Remove deprecated pre-1.0 APIs and give (#2171) published row metadata precedence over colliding selected fields. Structured source spreads and direct source-row returns keep source attribution; new functional objects and other projections receive output Collection metadata. Keep the two packages accidentally released as stable 1.x on their stable release lines. Both stable minor releases require
@tanstack/db@^1.0.0-rc.0for the RC health and restoration settlement APIs; upgrade DB with them.Remove Query Collection’s automatic refetch after mutation handlers. Handlers return
Promise<void>and must awaitcollection.utils.refetch()or write confirmed data with thewrite*utilities;{ refetch: false }is removed.
Minor Changes#
Collections now answer two questions separately: can the data be shown (
status), and is it still kept up to date (health). Once a query has shown data, a network or backend failure never takes it off the screen. (#2168)statusgainscrashed: local storage broke (a closed IndexedDB connection, a failed SQLite persistence write or restore, a throwing sync function, or an invariant failure). Nothing recovers it in place, andreload()rejects. To recover, callcleanup({ dependents: true }), then start the Collection again (for example withpreload()); it starts with no rows. It reaches every live query and Effect above it.errornow means only "the first load failed".- Every Collection has
collection.health, a health node withstatus,failureReason(the adapter is still trying),error(the adapter stopped, or the first load failed),reloading, andhasErrors. A live query'shealthhas one node per source alias, in query order, and keeps object identity while unchanged.health:changefires when it changes.findProblems(health)lists the nodes that have a problem, in query order. Each problem (HealthProblem) shows its newest failure inmessage,cause, andat, and lists every failure still open inerrors, oldest first: eachreportError()of the sync run untilreportHealthy(), or each failed request for more data on a live query's node. One error value is one failure: reporting it again changes nothing, andreportHealthy(error)removes just that failure, so a query Collection whose failing Query recovers removes only that Query's failures. After a live query is ready, a failed request for more data (a page, a joined row, or a source reload's replay of its data) is anerroron the query's own node; the source stays healthy. collection.reload()starts a new sync run and keeps the rows, status, and error on screen until the reload completes: when the new run's snapshot (begin({ snapshot: true })) ortruncate()applies, or at itsmarkReady(), which keeps the rows when no snapshot came. On a live query it reloads every Collection below it that shows anerror, through nested live queries, then the query itself when its own node has anerror, including a failed request for more data. It rejects on acrashedCollection. When the cleanup of the sync run that a reload retired rejects, the Collection crashes, also if the rejection comes later. A query inerrorstays there until itsreload().cleanup()rejects withCollectionHasSubscribersErrorwhile a live query with subscribers or an Effect reads the Collection.cleanup({ dependents: true })ends them first.collection.subscriberslists every dependent.- A local-only Collection's
reload()keeps its rows, including the user's writes:initialDataloads only when the Collection starts, or starts again after cleanup. - Persisted Collections have one status. With
initialRender: { strategy: 'network-first' }, restored rows make the Collectionreadyonce the deadline passes or the remote fails; an empty restore staysloading. Only a local storage failure crashes a persisted Collection: a failed remote subset request is a failure reason, which the next successful remote request clears.
Breaking changes and migration:
Before After hook isErrorisLoadingError(first load failed) orisCrashed— isSyncError:readyand the health tree has a problemstatus: 'error'after a crashstatus: 'crashed'adapter markError(error)fail(error). After readiness it sets the node'serrorand keeps the rows. Later calls throw.cleanup()thenpreload()to recoverreload()adapter begin({ direct: true })begin(): every write applies on the rows the Collection holds, also during a reloada reload's first commit replaced every row begin({ snapshot: true })ortruncate()in the new run replaces themadapter markReady()afterfail()threwit does nothing cleanup()while live queries or Effects read the Collectionrejects; unmount first or pass { dependents: true }persistedStatus,isPersistedReady,persistedError,preloadForInitialRender(),PERSISTED_READINESSstatusandhealthquery-db utils.lastError,utils.isError,utils.errorCount,utils.clearError()collection.health,reload()infinite-query hooks' error(React, Preact, Vue, Svelte)the root node's errorinhealth;fetchNextPage()still resolvesCustom sync adapters: keep the run's readiness in your
syncfunction. A reload callssyncagain whilecollection.statusstill shows the previous run's status and the Collection still holds the previous run's rows. The new run's writes apply on those rows; it replaces every row only with a snapshot, a transaction begun withbegin({ snapshot: true }), or with its owntruncate(). The reload completes when that replacement applies, or at the new run'smarkReady(), which keeps the rows when no snapshot came. So send the new run's full state as a snapshot, or write against the kept rows: aninsertof a key the Collection holds throwsDuplicateKeySyncError, during a reload as at any time, so writeupdatefor a kept row, also from a replayed load after the reload completed. A reload keeps every row its new run does not rewrite: core never deletes kept rows on its own, so removing a row the backend deleted is the adapter's job, through a snapshot, adelete, or row ownership (#2269). An on-demandloadSubsetresult is partial and is never a snapshot. A live query's own reload keeps its rows and its window until its new run's result is complete.reportError()andreportHealthy()throw before the firstmarkReady()and afterfail().markReady()after the run is ready, or after itsfail(), does nothing, so an adapter needs no flag of its own to guard it. A secondfail()in the same sync run does nothing. A first-ready callback that throws whilesyncruns is reported uncaught, and the Collection stays ready.reload()called from insidesyncor aloadSubsetcall rejects, unless a reload is already in flight, whose promise it returns. Calls after a crash do nothing. For an on-demand Collection, a reload aborts the retired run'sloadSubsetcalls and asks the new run'sloadSubsetfor the current demand as soon assyncreturns. Honor thesignal: when core aborts a load, that load is over for core, and its later resolve or reject decides nothing, holds no readiness, and no replay waits for it. AloadSubsetthat throws synchronously is a rejection: a failed load, whichrequestSnapshot()andsetWindow()report without throwing. A truncate's or reload's replay decides every request error of the query's demand: its success clears them all, and its failure replaces them with the replay's failures.useLiveSuspenseQuerynow throws an Error for a failed first load or a crash: the cause itself when it is an Error, otherwise an Error with the problem's message whosecauseholds the reported value.
Patch Changes#
- Updated dependencies [
5649a07,43d4ef6,7538afd,a07cd73,6c1ca8f,30175be,4c39add,1640de8,367ea7c,7d9ed02,45eeef8]:- @tanstack/db@1.0.0-rc.1
0.1.123#
Patch Changes#
0.1.122#
Patch Changes#
0.1.121#
Patch Changes#
0.1.120#
Patch Changes#
An on-demand TrailBase load now waits for the change subscription before it fetches rows. Before, a live query could become ready before the subscription started, and a change committed after the fetch but before the subscription was lost. (#2126)
Updated dependencies [
cda9d6a,2f928e6,dfec42e,1a65c2c,1b4ee8d,bbbf017,bc6f30e,fade2e2,bbe9327,b34a579,6fa60aa,f84387c,be4a3d6,0dc696a,fd13e3c]:- @tanstack/db@0.14.0
0.1.119#
Patch Changes#
- Updated dependencies [
f6aba31,faa3de6,bcb2af6,2ab7f3e,86f00ea,f7ac2c6,fa36267,2c98b49,f6d65ea,fe284cc,8b0e1de,4bd66cf]:- @tanstack/db@0.13.0
0.1.118#
Patch Changes#
- Updated dependencies [
487c5a6]:- @tanstack/db@0.12.3
0.1.117#
Patch Changes#
0.1.116#
Patch Changes#
- Updated dependencies [
d029833,aa1b58e,c3a4e4a,2376eb5,a37e69a,d029833,d029833,de8d0f1]:- @tanstack/db@0.12.1
0.1.115#
Patch Changes#
Add development-only collection configuration diagnostics. Missing or invalid core options throw actionable errors. Extra adapter properties remain accepted without warnings, except for likely misspellings: casing mistakes or adjacent letter swaps in option names with at least five characters. A suggestion is suppressed when the correctly named option is already present. Keep the validator, warnings, and internal diagnostic classes out of production application bundles. (#1278)
Keep adapter-specific options inside PowerSync, RxDB, and TrailBase. Update the adapter guide to keep conversions in adapter code and place rowUpdateMode inside the sync config.
Drop a transaction's optimistic state when its mutation function settles. A sync transaction committed while the transaction is persisting is accepted and held. It publishes together with that drop, and
isPersistedsettles after that publication. A mutation function that returns before its server row arrives shows the previous synced row until that row applies. A sync write is attributed$origin: 'local'only if it was accepted before the optimistic state dropped. A sync transaction still open at that point is not counted. (#2030)Breaking: remove the
begin({ immediate })option from the sync API. Writes made while a mutation persists now queue behind it instead of applying at once.Each sync transaction now has two moments: accepted and visible.
commit()receipts and subset loads resolve when the rows are visible. Collection readiness (preload,stateWhenReady,toArrayWhenReady) resolves once the startup rows are accepted, so a mutation handler that awaits its own collection's readiness during startup settles. An accepted transaction always applies. Handler-facing writes resolve at acceptance, so a mutation handler can await them: Query Collection direct writes, persisted mutation confirmation, and the PowerSync mutation path. A handler that awaits an on-demand load of its own collection waits for itself.A subset load whose caller aborts rejects with
AbortErrorat every point: before the fetch, when the fetch fails because of the abort, after the fetch but before the commit, and between pages. Pages that were already accepted still apply, and a TrailBase load waits until they are visible.Query Collection direct writes read and validate the accepted rows and update the Query cache after acceptance. A refetch no longer cancels an accepted result, so overlapping refetches of a persisted collection apply in order (#1990). An eager fetch that started before a direct write keeps the server's rows for every key the write did not touch and the accepted row for each key it did, in both the collection and the Query cache.
A DbClient hydration chunk is accepted ahead of a still-open source transaction, so readers of accepted rows see it and the source's
commit()still commits its own writes.Partial sync updates now keep an own
__proto__field. Metadata-only sync writes no longer publish a spurious insert when they apply with a held transaction. A rollback keeps its delete event when a sync transaction for the same key is still open. When two completed transactions hold one key, the newer transaction's row stays visible. Canceling any sync transaction other than the open last one throwsSyncQueueInvariantError.Updated dependencies [
2806da0,7c516ce,eac6e8b,a21f4a4,cfb03f2]:- @tanstack/db@0.12.0
0.1.114#
Patch Changes#
- Updated dependencies [
06cab6f]:- @tanstack/db@0.11.3
0.1.113#
Patch Changes#
- Updated dependencies [
dac687d,dac687d,dac687d,dac687d,7595a2d,dac687d,dac687d,8be6705]:- @tanstack/db@0.11.2
0.1.112#
Patch Changes#
- Updated dependencies [
a18f63d,e706483,18abcee,d2690bf,5b85af0,1dbf5f9,7ab48d8,d2690bf,7ca38db,f2f92c5]:- @tanstack/db@0.11.1
0.1.111#
Patch Changes#
- Updated dependencies [
9c62ac3,d5e4732,0122da8,f7d96f7,fb509ef,dc4b4e0,f158258,c879ba6,b5d92ce]:- @tanstack/db@0.11.0
0.1.110#
Patch Changes#
Prevent cursor-based pagination from also applying the fallback row offset. (#1893)
Updated dependencies [
2ad6834,b528a61,84fc44b,9351f46,5108acf,afbeb44,2775082,fef53f8,b44a50a,19dd9a2,3096b8f,1ab1cd3,e5fe2ea,3eb5b2b,7c62bf5,63362dc,7f6b643,c479fdc,91a2cbf,144c6b1,5218f0c,76d766e,1e54c6a,d698b90,04a1a81,3ad64a4,4c5a8de,b72b5d1,fc1adde,2781581,40a5aea,e16d46c,9cbc885,23ae52d,7917ef9,1ca838b,34a999d,825acc5,febd4bc,b7a7d10,510cb53,efb84d8,236d77b,71ad428]:- @tanstack/db@0.10.0
0.1.109#
Patch Changes#
- Updated dependencies [
3c4c35d]:- @tanstack/db@0.9.2
0.1.108#
Patch Changes#
Fix unhandled rejections and resource leaks when a TrailBase subscription closes, fails, or is cleaned up. Drain buffered events before releasing the reader and prevent a canceled startup from canceling a replacement sync session. (#1805)
Updated dependencies [
a378bd3,ad043b7,025a079,ddc129e]:- @tanstack/db@0.9.1
0.1.107#
Patch Changes#
- Updated dependencies [
cfb01ce]:- @tanstack/db@0.9.0
0.1.106#
Patch Changes#
- Updated dependencies [
bbc9edf]:- @tanstack/db@0.8.7
0.1.105#
Patch Changes#
- Updated dependencies [
ae2fe74]:- @tanstack/db@0.8.6
0.1.104#
Patch Changes#
- Settle subset loads only after their committed rows and events are visible. A (#1769)
commit receipt now rejects with
AbortErrorwhen cancellation wins before application and ignores later aborts. Preserve causal publication, cancellation, persistence, and error handling across the affected sync adapters. - Updated dependencies [
d8defd2,9ad882f,8c5838d]:- @tanstack/db@0.8.5
0.1.103#
Patch Changes#
Report incremental subset-load failures through subscriptions, live-query utilities, and effects while keeping cached source rows available. Recover cleanly from failed or overlapping must-refetch replays, collection cleanup, effect teardown errors, and cooperative adapter cancellation. Electric's shared-stream snapshot path still depends on upstream request identity or cancellation support to prevent rows from an aborted request from arriving before the request Promise settles. (#1756)
Updated dependencies [
3131de1,8f432ba]:- @tanstack/db@0.8.4
0.1.102#
Patch Changes#
0.1.101#
Patch Changes#
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. (#1751)Updated dependencies [
c521b5d]:- @tanstack/db@0.8.2
0.1.100#
Patch Changes#
0.1.99#
Patch Changes#
Add SSR through request-scoped
DbClientinstances, collection descriptors, (#1564) explicit collection-row hydration, live-query result snapshots, adapter sync metadata, and React and Svelte descriptor resolution.React live queries now derive identity from structured query IR. Opaque queries can provide
queryKey; legacy dependency arrays and unkeyed opaque queries keep working with development warnings until 1.0.Add TanStack Router integration that streams live queries discovered during a Suspense render as pending promises which resolve to ordered result snapshots. The browser starts normal source sync and atomically replaces the snapshot when its live result is ready.
Updated dependencies [
4b9e8cd]:- @tanstack/db@0.8.0
0.1.98#
Patch Changes#
- Updated dependencies [
5f63996]:- @tanstack/db@0.7.2
0.1.97#
Patch Changes#
- Updated dependencies [
424382b]:- @tanstack/db@0.7.1
0.1.96#
Patch Changes#
0.1.95#
Patch Changes#
- Updated dependencies [
8ee783d]:- @tanstack/db@0.6.17
0.1.94#
Patch Changes#
0.1.93#
Patch Changes#
0.1.92#
Patch Changes#
- Updated dependencies [
397e12a]:- @tanstack/db@0.6.14
0.1.91#
Patch Changes#
0.1.90#
Patch Changes#
- Updated dependencies [
2b27dd1]:- @tanstack/db@0.6.12
0.1.89#
Patch Changes#
0.1.88#
Patch Changes#
- Updated dependencies [
307fdf8]:- @tanstack/db@0.6.10
0.1.87#
Patch Changes#
0.1.86#
Patch Changes#
- Updated dependencies [
3827b62]:- @tanstack/db@0.6.8
0.1.85#
Patch Changes#
0.1.84#
Patch Changes#
- Updated dependencies [
4e9ab39]:- @tanstack/db@0.6.6
0.1.83#
Patch Changes#
0.1.82#
Patch Changes#
- Updated dependencies [
1e69dd6]:- @tanstack/db@0.6.4
0.1.81#
Patch Changes#
0.1.80#
Patch Changes#
0.1.79#
Patch Changes#
- Updated dependencies [
8b7fb1a]:- @tanstack/db@0.6.1
0.1.78#
Patch Changes#
Add TrailBase
syncModesupport and end-to-end coverage for eager and on-demand collection syncing. (#1098)Add a wider range of subset queries for TrailBase integration, including pagination, ordering, and basic
wheresupport. (#1101)Update dependencies across workspace to resolve version mismatches:
@electric-sql/client^1.5.13,@tanstack/store^0.9.2,pg^8.20.0. Adapt subscription cleanup to@tanstack/store0.9.x API which returnsSubscriptionobjects instead of unsubscribe functions. (#1381)Update TrailBase's client to v0.10 and lock-down server version for e2e tests. (#1398)
Updated dependencies [
f60384b,b8abc02,09c7afc,bb09eb1,179d666,43ecbfa,055fd94,055fd94,055fd94,055fd94,85f5435,b65d8f7,e0df07e,9952921,d351c67]:- @tanstack/db@0.6.0
0.1.77#
Patch Changes#
- Updated dependencies [
c3e6a96]:- @tanstack/db@0.5.33
0.1.76#
Patch Changes#
0.1.75#
Patch Changes#
- Updated dependencies [
bf1d078]:- @tanstack/db@0.5.31
0.1.74#
Patch Changes#
- Updated dependencies [
e9d0fd8]:- @tanstack/db@0.5.30
0.1.73#
Patch Changes#
0.1.72#
Patch Changes#
- Updated dependencies [
46450e7]:- @tanstack/db@0.5.28
0.1.71#
Patch Changes#
Make type of collection utils more precise for localOnly, PowerSync, Trailbase, and Electric collections (#1236)
Updated dependencies [
802550f,dc41d7d,4ff3da5,2223cd6]:- @tanstack/db@0.5.27
0.1.70#
Patch Changes#
0.1.69#
Patch Changes#
0.1.68#
Patch Changes#
- Updated dependencies [
7099459]:- @tanstack/db@0.5.24
0.1.67#
Patch Changes#
- Updated dependencies [
05130f2]:- @tanstack/db@0.5.23
0.1.66#
Patch Changes#
- Updated dependencies [
f9b741e]:- @tanstack/db@0.5.22
0.1.65#
Patch Changes#
0.1.64#
Patch Changes#
- Updated dependencies []:
- @tanstack/db@0.5.20
0.1.63#
Patch Changes#
0.1.62#
Patch Changes#
- Updated dependencies [
c1247e8]:- @tanstack/db@0.5.18
0.1.61#
Patch Changes#
0.1.60#
Patch Changes#
- Updated dependencies [
41308b8]:- @tanstack/db@0.5.16
0.1.59#
Patch Changes#
- Updated dependencies [
32ec4d8]:- @tanstack/db@0.5.15
0.1.58#
Patch Changes#
- Updated dependencies [
26ed0aa]:- @tanstack/db@0.5.14
0.1.57#
Patch Changes#
0.1.56#
Patch Changes#
0.1.55#
Patch Changes#
0.1.54#
Patch Changes#
0.1.53#
Patch Changes#
- Updated dependencies [
5f474f1]:- @tanstack/db@0.5.9
0.1.52#
Patch Changes#
0.1.51#
Patch Changes#
- Updated dependencies [
295cb45]:- @tanstack/db@0.5.7
0.1.50#
Patch Changes#
- Updated dependencies [
c8a2c16]:- @tanstack/db@0.5.6
0.1.49#
Patch Changes#
- Updated dependencies [
077fc1a]:- @tanstack/db@0.5.5
0.1.48#
Patch Changes#
0.1.47#
Patch Changes#
0.1.46#
Patch Changes#
- Updated dependencies [
99a3716]:- @tanstack/db@0.5.2
0.1.45#
Patch Changes#
- Updated dependencies [
a83a818]:- @tanstack/db@0.5.1
0.1.44#
Patch Changes#
- Updated dependencies [
243a35a,f9d11fc,7aedf12,28f81b5,28f81b5,f6ac7ea,01093a7]:- @tanstack/db@0.5.0
0.1.43#
Patch Changes#
Trigger new release for trailbase-db-collection
Version 0.1.42 was already published to npm. This changeset bumps the version to 0.1.43 to allow for a new release.
0.1.42#
Patch Changes#
0.1.41#
Patch Changes#
- Updated dependencies [
75470a8]:- @tanstack/db@0.4.19
0.1.40#
Patch Changes#
0.1.39#
Patch Changes#
- Updated dependencies [
49bcaa5]:- @tanstack/db@0.4.17
0.1.38#
Patch Changes#
0.1.37#
Patch Changes#
- Updated dependencies [
6738247]:- @tanstack/db@0.4.15
0.1.36#
Patch Changes#
- Updated dependencies [
970616b]:- @tanstack/db@0.4.14
0.1.35#
Patch Changes#
- Updated dependencies [
3c9526c]:- @tanstack/db@0.4.13
0.1.34#
Patch Changes#
0.1.33#
Patch Changes#
- Updated dependencies [
5566b26]:- @tanstack/db@0.4.11
0.1.32#
Patch Changes#
0.1.31#
Patch Changes#
0.1.30#
Patch Changes#
0.1.29#
Patch Changes#
- Updated dependencies [
6692aad]:- @tanstack/db@0.4.7
0.1.28#
Patch Changes#
0.1.27#
Patch Changes#
- Updated dependencies [
7556fb6]:- @tanstack/db@0.4.5
0.1.26#
Patch Changes#
0.1.25#
Patch Changes#
- Updated dependencies [
32f2212]:- @tanstack/db@0.4.3
0.1.24#
Patch Changes#
0.1.23#
Patch Changes#
- Updated dependencies [
8cd0876]:- @tanstack/db@0.4.1
0.1.22#
Patch Changes#
0.1.21#
Patch Changes#
- Updated dependencies [
cacfca2]:- @tanstack/db@0.3.2
0.1.20#
Patch Changes#
- Updated dependencies [
5f51f35]:- @tanstack/db@0.3.1
0.1.19#
Patch Changes#
0.1.18#
Patch Changes#
Define BaseCollectionConfig interface and let all collections extend it. (#531)
Updated dependencies [
b03894d,3968087]:- @tanstack/db@0.2.5
0.1.17#
Patch Changes#
0.1.16#
Patch Changes#
- Updated dependencies [
b162556]:- @tanstack/db@0.2.3
0.1.15#
Patch Changes#
- Updated dependencies [
33515c6]:- @tanstack/db@0.2.2
0.1.14#
Patch Changes#
- Updated dependencies [
620ebea]:- @tanstack/db@0.2.1
0.1.13#
Patch Changes#
0.1.12#
Patch Changes#
- Updated dependencies [
cc4c34a]:- @tanstack/db@0.1.12
0.1.11#
Patch Changes#
- Updated dependencies [
b869f68]:- @tanstack/db@0.1.11
0.1.10#
Patch Changes#
0.1.9#
Patch Changes#
- Updated dependencies [
d64b4a8]:- @tanstack/db@0.1.9
0.1.8#
Patch Changes#
0.1.7#
Patch Changes#
0.1.6#
Patch Changes#
- Updated dependencies [
ad33e9e]:- @tanstack/db@0.1.6
0.1.5#
Patch Changes#
- Updated dependencies [
9a5a20c]:- @tanstack/db@0.1.5
0.1.4#
Patch Changes#
0.1.3#
Patch Changes#
- Updated dependencies [
0cb7699]:- @tanstack/db@0.1.3
0.1.2#
Patch Changes#
0.1.1#
Patch Changes#
0.1.0#
Minor Changes#
- 0.1 release - first beta 🎉 (#332)
Patch Changes#
0.0.9#
Patch Changes#
- Updated dependencies [
6e8d7f6]:- @tanstack/db@0.0.33
0.0.8#
Patch Changes#
- Updated dependencies [
e04bd12]:- @tanstack/db@0.0.32
0.0.7#
Patch Changes#
- Updated dependencies [
3e9a36d]:- @tanstack/db@0.0.31
0.0.6#
Patch Changes#
- Updated dependencies [
6bdde55]:- @tanstack/db@0.0.30
0.0.5#
Patch Changes#
feat: Replace string-based errors with named error classes for better error handling (#297)
This comprehensive update replaces all string-based error throws throughout the TanStack DB codebase with named error classes, providing better type safety and developer experience.
New Features#
- Root
TanStackDBErrorclass - all errors inherit from a common base for unified error handling - Named error classes organized by package and functional area
- Type-safe error handling using
instanceofchecks instead of string matching - Package-specific error definitions - each adapter has its own error classes
- Better IDE support with autocomplete for error types
Package Structure#
Core Package (
@tanstack/db)#Contains generic errors used across the ecosystem:
- Collection configuration, state, and operation errors
- Transaction lifecycle and mutation errors
- Query building, compilation, and execution errors
- Storage and serialization errors
Adapter Packages#
Each adapter now exports its own specific error classes:
@tanstack/electric-db-collection: Electric-specific errors@tanstack/trailbase-db-collection: TrailBase-specific errors@tanstack/query-db-collection: Query collection specific errors
Breaking Changes#
- Error handling code using string matching will need to be updated to use
instanceofchecks - Some error messages may have slight formatting changes
- Adapter-specific errors now need to be imported from their respective packages
Migration Guide#
Core DB Errors#
Before:
try { collection.insert(data) } catch (error) { if (error.message.includes('already exists')) { // Handle duplicate key error } }After:
import { DuplicateKeyError } from '@tanstack/db' try { collection.insert(data) } catch (error) { if (error instanceof DuplicateKeyError) { // Type-safe error handling } }Adapter-Specific Errors#
Before:
// Electric collection errors were imported from @tanstack/db import { ElectricInsertHandlerMustReturnTxIdError } from '@tanstack/db'After:
// Now import from the specific adapter package import { ElectricInsertHandlerMustReturnTxIdError } from '@tanstack/electric-db-collection'Unified Error Handling#
New:
import { TanStackDBError } from '@tanstack/db' try { // Any TanStack DB operation } catch (error) { if (error instanceof TanStackDBError) { // Handle all TanStack DB errors uniformly console.log('TanStack DB error:', error.message) } }Benefits#
- Type Safety: All errors now have specific types that can be caught with
instanceof - Unified Error Handling: Root
TanStackDBErrorclass allows catching all library errors with a single check - Better Package Separation: Each adapter manages its own error types
- Developer Experience: Better IDE support with autocomplete for error types
- Maintainability: Error definitions are co-located with their usage
- Consistency: Uniform error handling patterns across the entire codebase
All error classes maintain the same error messages and behavior while providing better structure and package separation.
- Root
Updated dependencies [
ced0657,dcfef51,360b0df,608be0c,5260ee3]:- @tanstack/db@0.0.29
0.0.4#
Patch Changes#
0.0.3#
Patch Changes#
- Updated dependencies [
bec8620]:- @tanstack/db@0.0.27
0.0.2#
Patch Changes#
Add initial release of TrailBase collection for TanStack DB. TrailBase is a blazingly fast, open-source alternative to Firebase built on Rust, SQLite, and V8. It provides type-safe REST and realtime APIs with sub-millisecond latencies, integrated authentication, and flexible access control - all in a single executable. This collection type enables seamless integration with TrailBase backends for high-performance real-time applications. (#228)
Updated dependencies [
09c6995]:- @tanstack/db@0.0.26