Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

CHANGELOG.md

1,427 lines75.7 KB

@tanstack/electric-db-collection

0.5.1

Patch Changes

0.5.0

Minor Changes

  • Deprecation: Mutation handler return values and QueryCollection auto-refetch behavior. (#843)

    What's changed:

    • Handler return values remain type-compatible during the deprecation window
    • Deprecation warnings are logged when deprecated patterns are used

    QueryCollection changes:

    • Auto-refetch after handlers is deprecated and will be removed in v1.0
    • To skip auto-refetch now, return { refetch: false } from your handler
    • To migrate to explicit refetch now, await collection.utils.refetch() and return { refetch: false } to prevent a second fetch; remove the return in v1.0
    • In v1.0, call await collection.utils.refetch() explicitly when needed, or omit it to skip

    ElectricCollection changes:

    • Returning { txid } is deprecated - use await collection.utils.awaitTxId(txid) instead
    • The default awaitTxId and awaitMatch timeouts increase to 15 seconds

    Migration guide:

    // QueryCollection - skip refetch (current)
    onInsert: async ({ transaction }) => {
      await api.create(transaction.mutations[0].modified)
      return { refetch: false } // Opt out of auto-refetch
    }
    
    // QueryCollection - migrate to explicit refetch now
    onInsert: async ({ transaction, collection }) => {
      await api.create(transaction.mutations[0].modified)
      await collection.utils.refetch() // Explicit refetch
      return { refetch: false } // Prevent a second pre-1.0 refetch; remove in v1.0
    }
    
    // ElectricCollection - before
    onInsert: async ({ transaction }) => {
      const result = await api.create(transaction.mutations[0].modified)
      return { txid: result.txid } // Deprecated
    }
    
    // ElectricCollection - after
    onInsert: async ({ transaction, collection }) => {
      const result = await api.create(transaction.mutations[0].modified)
      await collection.utils.awaitTxId(result.txid) // Explicit
    }
  • Preserve collection key and adapter utility types throughout mutation handlers and nested transaction mutations. Mutation keys now use the collection's declared key type instead of any; collections that use the default key type expose string | number. Prevent Query and Electric collections from exposing nonexistent cross-adapter utilities. (#1849)

Patch Changes

  • Preserve PostgreSQL semantics for boolean comparisons and array membership, (#1832) including nullable values, compatible reference-to-array types, and non-text array elements. Reject nullish membership operands and literal-array left operands, and escape quotes in mapped column names.

  • Retain retry-stable Suspense resources and preserve persisted demand readiness across lifecycle transitions. Avoid redundant Electric refreshes when requesting subset snapshots, and declare React 18 as the minimum supported React version. (#1860)

  • Fail-stop persisted collections when hydration or durability fails, and replay authoritative source transactions through one persistence-owned FIFO. Electric collections keep optimistic state immediate while surfacing durable failures through the collection error state instead of continuing from an incomplete baseline. (#1853)

    Query collections retain ownership metadata that the persisted wrapper already published instead of restoring stale ownership after the publication boundary.

  • Preserve persisted resume integrity with atomic SQLite baseline evidence and stale-writer rejection, expose persistence sync metadata as one versioned capability, and refresh uncertified Electric baselines before publishing resumed data. (#1846)

    This changes the public persistence contracts: custom PersistenceAdapter implementations must now implement loadResumeSnapshot, and SyncMetadataApi.persistence is required with null explicitly representing no persistence. Custom sync wrappers that receive metadata must forward metadata.persistence unchanged so consumers receive either that sentinel or the complete versioned capability. A direct sync invocation may still omit the optional metadata object entirely, which consumers treat as no persistence. The Electron bridge now transports the atomic resume snapshot through IPC protocol v2; Electron main and renderer integrations must upgrade together because mixed v1/v2 peers fail closed. Node and React Native persistence instances that wrap one database handle now share transaction admission so concurrent collection startup cannot overlap transactions on that connection.

  • 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.4.10

Patch Changes

  • Preserve nested boolean predicate grouping when compiling Electric subset SQL, (#1816) including comparison results and NOT expressions used inside comparisons, membership checks, and null tests.
  • Updated dependencies [3c4c35d]:
    • @tanstack/db@0.9.2

0.4.9

Patch Changes

  • Harden Electric resume and lifecycle handling so partial updates cannot materialize unknown or moved-out rows, stale async work and waiters cannot cross cleanup or restart—including automatic garbage collection—and valid batches behave the same across callback partitions and persistence hydration. (#1785)

    Preserve hydrated baseline rows during persistence reloads, accept complete-row updates from explicit full-replica resumes, retain committed match evidence until reset, and restart persisted resumes when hydration completion cannot be verified.

    Replace stale cached rows atomically when an invalid resume falls back to a fresh snapshot. Keep subset acquisitions from restoring logically removed rows, and isolate utilities and tag visibility when collection options are reused while preserving compatible same-collection resume state.

    Accept partial updates to complete rows published independently by persistence, while preserving pending removal and reset boundaries. Avoid copying all applied keys at startup or each subset acquisition; presence checks overlay queued writes and buffered messages once per stream callback. Warn once when an older persistence adapter cannot verify hydration for safe resume.

    Keep buffered tag move-outs inside the progressive snapshot's existing transaction so later live updates are not discarded behind an orphaned truncate.

    Keep copied materialized configs and reentrant match callbacks scoped to their owning collection session. Cold tagged or legacy persisted state now recovers with a full snapshot behind cached rows, including in on-demand mode. Keep the reset marker through interrupted recovery and publish the replacement only after the full snapshot completes; known untagged and compatible warm resumes retain their saved offset.

  • Updated dependencies [a378bd3, ad043b7, 025a079, ddc129e]:

    • @tanstack/db@0.9.1

0.4.8

Patch Changes

  • Fix on-demand load settlement, ordered pagination, and replay to preserve coherent results across cancellation, failure, cleanup, and restart. Preserve subset results and ownership across Electric, PowerSync, Query, and SQLite persistence adapters. Correct live-query grouping, include projections, value identity, and indexed comparisons. D2 hashing now rejects structural cycles and excessive traversal depth or work with an explicit error; Collection handles retain object-reference identity without traversing their mutable contents. (#1797)

    Remove the unused public subset-algebra helpers: isWhereSubset, unionWherePredicates, minusWherePredicates, isOrderBySubset, isLimitSubset, isOffsetLimitSubset, isPredicateSubset, and isLoadSubsetRequestSubsumedBy. Apps that import these helpers must remove those imports; normal queries and adapters are unaffected. DeduplicatedLoadSubset remains available and shares only exact demand identities.

    Reject compiled Collection-valued includes as fn.select() inputs, including nested descendants, before invoking the callback. Use toArray() or materialize() in the upstream .select() for child-value calculations. To keep live child Collections, use expression .select() or perform parent-only functional work before adding the includes. Ordinary Collection-valued includes remain supported.

    Remove proxy DEBUG logging and automatic index timing statistics to avoid diagnostic work on reads and writes. Remove getStats() and IndexStats; use index.keyCount for the current entry count, and instrument index methods externally when profiling. Custom index subclasses must remove calls to the retired trackLookup() and updateTimestamp() helpers.

    Fix mutation drafts so Map/Set forEach calls each callback once and read-only iteration reports no changes. Track nested Map for...of edits through collection.update(). Keep Set entries in place during nested edits, preserving live iteration and usable has, delete, and add handles without duplicate entries or repeated visits. Reverting one entry no longer discards another entry's pending changes.

    Preserve shared values within a row's draft. Newly supplied objects use normal shared references during the update callback, including Map values and Set members; editing through either handle changes the same new object. Copy completed changes at callback return so later caller edits cannot mutate stored data. Existing collection values remain isolated. Copy a new caller-owned value before insertion if it must remain untouched during the callback.

    Keep rejected local-storage mutations out of later successful saves. Stage insert, update, delete, and manual transaction writes before persisting, then promote the shared cache only after storage succeeds.

    Deliver live-query observer publications to peer listeners even when one listener throws. Preserve queued publication order and stop delivery on disposal; report the first listener failure after delivery.

    Wait for PowerSync demands admitted during tracking finalization before reporting them loaded. Preserve untouched object and array key identity when they contain NaN. Retire every failed ordered acquisition on explicit retry, while retaining a full-source demand repaired by replay.

    After authoritative ordered recovery succeeds, retire settled page and tie demands so later truncate replay fetches only the full-source replacement. Keep unfinished requests observed until settlement and preserve independent query ownership.

    Remove the live-query utils.getRunCount() diagnostic and its runtime counter. Apps that call this diagnostic must remove those calls. Query scheduling and results are unchanged.

    Remove test-only index inspection getters (indexedKeysSet, valueMapData, orderedEntriesArray, and orderedEntriesArrayReversed) and unused scheduler diagnostics. ReverseIndex now exposes only the IndexReader lookup, range, and forward traversal surface returned by findIndexForField; mutate the original index instead. Export IndexReader for callers that name this return type. Remove the unused subscription releaseLoadSubset() method; request owners use the release callback supplied by onLoadSubsetResult. Ordinary query and adapter APIs remain unchanged by these removals.

    Remove unused internal helpers and the unused public error classes WhereClauseConversionError, SubscriptionNotFoundError, and AggregateNotSupportedError. These classes have no remaining runtime throw sites; remove any imports of them. Keep the existing query and index behavior and exercise identity/evaluation tests through the production entry points.

    Ensure failed mutations roll back even when their rejection value cannot be converted to a string. Preserve ordinary Error instances; report unprintable rejection values as Unknown error.

    Make reentrant effect disposal share the active cleanup result, including calls from abort listeners or source release callbacks. A release failure reaches every waiting disposer while each source still receives one release attempt.

    Reject starting or preloading a collection from inside its active cleanup callbacks with a clear CollectionStateError. Nested cleanup cannot admit replacement work that the old teardown would discard. Restart after cleanup completes, or from its final cleaned-up status event, remains supported.

    Prevent older page or tie-boundary completions from clearing a newer full-source failure or starting redundant loading. Failed window moves retain their settled public snapshot; an explicit retry releases the failed acquisition once and publishes the completed replacement.

    Restrict direct subscription requestLimitedSnapshot() cursor inputs to one order term and one minValues entry. Composite and partial-composite cursor inputs now throw before local delivery or adapter work. Use normal live-query ordering and window APIs for multi-column pagination; those remain supported through prefix-and-tie loading. Existing adapters need no changes.

    Treat LoadSubsetOptions and their nested request data as immutable from submission onward. Core no longer copies expression trees or mutable constant payloads at the sync and deduplication boundaries. Create a new Date, byte array, membership array, or options object when changing a demand instead of mutating submitted data. Adapters must also leave request data unchanged. Use stable data properties rather than stateful getters. AbortSignal cancellation and subscription release remain live.

    Replace replay acquisitions sequentially: release the prior physical lease before starting its replacement. The logical demand and last complete public result remain retained. A failed release prevents replacement startup; failed startup leaves demand available for a later authoritative replay. Custom adapters must support a release/load gap and preserve resources still held by other owners; a sole underlying resource may stop and restart.

  • Updated dependencies [cfb01ce]:

    • @tanstack/db@0.9.0

0.4.7

Patch Changes

  • Updated dependencies [bbc9edf]:
    • @tanstack/db@0.8.7

0.4.6

Patch Changes

  • Updated dependencies [ae2fe74]:
    • @tanstack/db@0.8.6

0.4.5

Patch Changes

  • Settle subset loads only after their committed rows and events are visible. A (#1769) commit receipt now rejects with AbortError when 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.4.4

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.4.3

Patch Changes

0.4.2

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.4.1

Patch Changes

0.4.0

Minor Changes

  • Add SSR through request-scoped DbClient instances, 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.

Patch Changes

  • Updated dependencies [4b9e8cd]:
    • @tanstack/db@0.8.0

0.3.18

Patch Changes

  • Updated dependencies [5f63996]:
    • @tanstack/db@0.7.2

0.3.17

Patch Changes

  • Updated dependencies [424382b]:
    • @tanstack/db@0.7.1

0.3.16

Patch Changes

0.3.15

Patch Changes

  • Updated dependencies [8ee783d]:
    • @tanstack/db@0.6.17

0.3.14

Patch Changes

  • Prevent progressive Electric collections from truncating persisted rows when resuming from saved Electric shape metadata. (#1493)

  • Bound the wait for Electric stream refreshes before loading on-demand subsets so native fetch implementations that do not promptly abort long polls do not keep live queries loading until the poll times out. (#1575)

  • Updated dependencies [8258d09, 286964d]:

    • @tanstack/db@0.6.16

0.3.13

Patch Changes

0.3.12

Patch Changes

  • Updated dependencies [397e12a]:
    • @tanstack/db@0.6.14

0.3.11

Patch Changes

0.3.10

Patch Changes

  • Updated dependencies [2b27dd1]:
    • @tanstack/db@0.6.12

0.3.9

Patch Changes

0.3.8

Patch Changes

  • Updated dependencies [307fdf8]:
    • @tanstack/db@0.6.10

0.3.7

Patch Changes

0.3.6

Patch Changes

  • Updated dependencies [3827b62]:
    • @tanstack/db@0.6.8

0.3.5

Patch Changes

0.3.4

Patch Changes

  • Updated dependencies [4e9ab39]:
    • @tanstack/db@0.6.6

0.3.3

Patch Changes

0.3.2

Patch Changes

  • Updated dependencies [1e69dd6]:
    • @tanstack/db@0.6.4

0.3.1

Patch Changes

0.3.0

Minor Changes

  • feat: add DNF/active_conditions support for arbitrary boolean WHERE clauses (#1270)

    Support the new Electric server wire protocol (electric-sql/electric#3791). Tags now use / delimiter with empty segments for non-participating positions. Shapes with subquery dependencies send active_conditions headers and use DNF evaluation for row visibility. Simple shapes without subqueries retain existing empty-tag-set deletion behavior.

Patch Changes

0.2.43

Patch Changes

  • Updated dependencies [8b7fb1a]:
    • @tanstack/db@0.6.1

0.2.42

Patch Changes

  • fix(persistence): harden persisted startup, truncate metadata semantics, and resume identity matching (#1380)

    • Restore persisted wrapper markReady fallback behavior so startup failures do not leave collections stuck in loading state
    • Replace load cancellation reference identity tracking with deterministic load keys for loadSubset / unloadSubset
    • Document intentional truncate behavior where collection-scoped metadata writes are preserved across truncate transactions
    • Tighten SQLite applied_tx migration handling to only ignore duplicate-column add errors
    • Stabilize Electric shape identity serialization so persisted resume compatibility does not depend on object key insertion order
  • 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/store 0.9.x API which returns Subscription objects instead of unsubscribe functions. (#1381)

  • Updated dependencies [f60384b, b8abc02, 09c7afc, bb09eb1, 179d666, 43ecbfa, 055fd94, 055fd94, 055fd94, 055fd94, 85f5435, b65d8f7, e0df07e, 9952921, d351c67]:

    • @tanstack/db@0.6.0

0.2.41

Patch Changes

  • Updated dependencies [c3e6a96]:
    • @tanstack/db@0.5.33

0.2.40

Patch Changes

0.2.39

Patch Changes

  • fix(electric-db-collection): Upgrade to latest electric client version (#1337)

0.2.38

Patch Changes

  • fix(electric-db-collection): Upgrade to latest electric client version (#1321)

  • Updated dependencies [bf1d078]:

    • @tanstack/db@0.5.31

0.2.37

Patch Changes

  • Updated dependencies [e9d0fd8]:
    • @tanstack/db@0.5.30

0.2.36

Patch Changes

  • Upgrade @electric-sql/client dependency from ^1.5.3 to ^1.5.8 (#1291)

  • Updated dependencies [77b815e, ac4ce67]:

    • @tanstack/db@0.5.29

0.2.35

Patch Changes

  • Fix isNull predicate causing LiveQuery to never become ready when offline. Reorder predicate checks in isWhereSubsetInternal so OR superset handling runs before AND subset decomposition, allowing and(eq, isNull) to match structurally equal disjuncts. Also separate forceDisconnectAndRefresh error handling into its own try-catch with correct error attribution. (#1275)

  • Updated dependencies [46450e7]:

    • @tanstack/db@0.5.28

0.2.34

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.2.33

Patch Changes

0.2.32

Patch Changes

  • Upgrade @electric-sql/client to ^1.5.3 (#1233)

0.2.31

Patch Changes

0.2.30

Patch Changes

  • Updated dependencies [7099459]:
    • @tanstack/db@0.5.24

0.2.29

Patch Changes

  • Fix unhandled 409 errors during collection cleanup. When a collection is cleaned up while snapshot requests are in-flight, errors are now properly caught and ignored rather than propagating as unhandled promise rejections. (#1174)

0.2.28

Patch Changes

  • Updated dependencies [05130f2]:
    • @tanstack/db@0.5.23

0.2.27

Patch Changes

  • Updated dependencies [f9b741e]:
    • @tanstack/db@0.5.22

0.2.26

Patch Changes

0.2.25

Patch Changes

  • Fix empty string values being incorrectly omitted from SQL query params. Queries like eq(column, '') now correctly include the empty string parameter instead of producing a malformed query with a missing $1 value. (#1146)

0.2.24

Patch Changes

  • Updated dependencies []:
    • @tanstack/db@0.5.20

0.2.23

Patch Changes

0.2.22

Patch Changes

  • Updated dependencies [c1247e8]:
    • @tanstack/db@0.5.18

0.2.21

Patch Changes

  • Fix orphan transactions after must-refetch in progressive sync mode (#1069)

    When a must-refetch message was received in progressive mode, it started a transaction with truncate() but reset hasReceivedUpToDate, causing subsequent messages to be buffered instead of written to the existing transaction. On up-to-date, the atomic swap code would create a new transaction, leaving the first one uncommitted forever. This caused collections to become corrupted with undefined values.

    The fix ensures that when a transaction is already started (e.g., from must-refetch), messages are written directly to it instead of being buffered for atomic swap.

  • Fix duplicate key error when overlapping subset queries return the same row with different values. (#1070)

    When multiple subset queries return the same row (e.g., different WHERE clauses that both match the same record), the server sends insert operations for each response. If the row's data changed between requests (e.g., timestamp field updated), this caused a DuplicateKeySyncError. The adapter now tracks synced keys and converts subsequent inserts to updates.

  • Updated dependencies [f795a67, d542667, 6503c09, b1cc4a7]:

    • @tanstack/db@0.5.17

0.2.20

Patch Changes

  • Updated dependencies [41308b8]:
    • @tanstack/db@0.5.16

0.2.19

Patch Changes

  • Fix slow onInsert awaitMatch performance issue (#1062)

    The message buffer was being cleared at the start of each new batch, causing messages to be lost when multiple batches (including heartbeats) arrived before awaitMatch was called. This resulted in awaitMatch timing out (~3-5s per attempt) and transaction rollbacks.

    The fix removes the buffer clearing between batches. Messages are now preserved until the buffer reaches MAX_BATCH_MESSAGES (1000), at which point the oldest messages are dropped. This ensures awaitMatch can find messages even when sync activity arrives before the API call completes.

0.2.18

Patch Changes

  • Updated dependencies [32ec4d8]:
    • @tanstack/db@0.5.15

0.2.17

Patch Changes

  • Updated dependencies [26ed0aa]:
    • @tanstack/db@0.5.14

0.2.16

Patch Changes

  • Adds support for the new subset-end message introduced in Electric. (#1004)

  • Support tagged rows and move out events in Electric collection. (#942)

  • Updated dependencies [8ed7725, 01452bf]:

    • @tanstack/db@0.5.13

0.2.15

Patch Changes

  • Don't pin @electric-sql/client version (#1031)

0.2.14

Patch Changes

  • Fix awaitMatch race condition on inserts and export isChangeMessage/isControlMessage. (#1000)

    Bug fixes:

    • Fixed race condition where awaitMatch would timeout on inserts when Electric synced faster than the API call
    • Messages are now preserved in buffer until next batch arrives, allowing awaitMatch to find them
    • Added batchCommitted flag to track commit state, consistent with awaitTxId semantics
    • Fixed batchCommitted to also trigger on snapshot-end in on-demand mode (matching "ready" semantics)

    Export fixes:

    • isChangeMessage and isControlMessage are now exported from the package index as documented
  • Fix invalid Electric proxy queries with missing params for null/undefined values (#951)

    When comparison operators were used with null/undefined values, the SQL compiler would generate placeholders ($1, $2) in the WHERE clause but skip adding the params to the dictionary. This resulted in invalid queries being sent to Electric.

    Now all comparison operators (eq, gt, lt, gte, lte, like, ilike) throw a clear error when used with null/undefined values, since comparisons with NULL always evaluate to UNKNOWN in SQL. Users should use isNull() or isUndefined() to check for null values instead.

0.2.13

Patch Changes

  • Enhanced LoadSubsetOptions with separate cursor expressions and offset for flexible pagination. (#960)

    ⚠️ Breaking Change for Custom Sync Layers / Query Collections:

    LoadSubsetOptions.where no longer includes cursor expressions for pagination. If you have a custom sync layer or query collection that implements loadSubset, you must now handle pagination separately:

    • Cursor-based pagination: Use the new cursor property (cursor.whereFrom and cursor.whereCurrent) and combine them with where yourself
    • Offset-based pagination: Use the new offset property

    Previously, cursor expressions were baked into the where clause. Now they are passed separately so sync layers can choose their preferred pagination strategy.

    Changes:

    • Added CursorExpressions type with whereFrom, whereCurrent, and optional lastKey properties
    • Added cursor to LoadSubsetOptions for cursor-based pagination (separate from where)
    • Added offset to LoadSubsetOptions for offset-based pagination support
    • Electric sync layer now makes two parallel requestSnapshot calls when cursor is present:
      • One for whereCurrent (all ties at boundary, no limit)
      • One for whereFrom (rows after cursor, with limit)
    • Query collection serialization now includes offset for query key generation
    • Added truncate event to collections, emitted when synced data is truncated (e.g., after must-refetch)
    • Fixed setWindow pagination: cursor expressions are now correctly built when paging through results
    • Fixed offset tracking: loadNextItems now passes the correct window offset to prevent incorrect deduplication
    • CollectionSubscriber now listens for truncate events to reset cursor tracking state

    Benefits:

    • Sync layers can choose between cursor-based or offset-based pagination strategies
    • Electric can efficiently handle tie-breaking with two targeted requests
    • Better separation of concerns between filtering (where) and pagination (cursor/offset)
    • setWindow correctly triggers backend loading for subsequent pages in multi-column orderBy queries
    • Cursor state is properly reset after truncation, preventing stale cursor data from being used
  • Updated dependencies [b3b1940, 09da081, 86ad40c]:

    • @tanstack/db@0.5.12

0.2.12

Patch Changes

0.2.11

Patch Changes

  • Type utils in collection options as specific type (e.g. ElectricCollectionUtils) instead of generic UtilsRecord. (#940)

  • fix: Add BigInt support to pg-serializer and fix error message for non-JSON-serializable values (#932)

    • Added support for serializing BigInt values to strings in the serialize function
    • Fixed the error message when encountering unsupported types to handle values that cannot be serialized by JSON.stringify (like BigInt), preventing a secondary error from masking the original issue
  • Updated dependencies [1d19d22, b3e4e80]:

    • @tanstack/db@0.5.10

0.2.10

Patch Changes

  • Updated dependencies [5f474f1]:
    • @tanstack/db@0.5.9

0.2.9

Patch Changes

  • Fix eager mode incorrectly committing data on snapshot-end before receiving the first up-to-date message. The snapshot-end in the Electric log can be from a significant period before the stream is actually up to date, so commits should only occur on up-to-date (or on snapshot-end after the first up-to-date has been received). This change does not affect on-demand mode where snapshot-end correctly triggers commits, or progressive mode which was already protected by its buffering mechanism. (#924)

0.2.8

Patch Changes

0.2.7

Patch Changes

  • Updated dependencies [295cb45]:
    • @tanstack/db@0.5.7

0.2.6

Patch Changes

  • Updated dependencies [c8a2c16]:
    • @tanstack/db@0.5.6

0.2.5

Patch Changes

  • Updated dependencies [077fc1a]:
    • @tanstack/db@0.5.5

0.2.4

Patch Changes

  • Fixed bug where like() and ilike() operators were not working in on-demand mode. The SQL compiler was incorrectly treating these operators as function calls (LIKE(column, pattern)) instead of binary operators (column LIKE pattern). Now like() and ilike() correctly compile to SQL binary operator syntax, enabling search queries with pattern matching in on-demand mode. This fix supports patterns like like(lower(offers.title), '%search%') and combining multiple conditions with or(). (#884)

  • Fix progressive mode to use fetchSnapshot and atomic swap (#852)

    Progressive mode was broken because requestSnapshot() injected snapshots into the stream in causally correct position, which didn't work properly with the full mode stream. This release fixes progressive mode by:

    Core Changes:

    • Use fetchSnapshot() during initial sync to fetch and apply snapshots immediately in sync transactions
    • Buffer all stream messages during initial sync (renamed flag to isBufferingInitialSync)
    • Perform atomic swap on first up-to-date: truncate snapshot data → apply buffered messages → mark ready
    • Track txids/snapshots only after atomic swap (enables correct optimistic transaction confirmation)

    Test Infrastructure:

    • Added ELECTRIC_TEST_HOOKS symbol for test control (hidden from public API)
    • Added progressiveTestControl.releaseInitialSync() to E2E test config for explicit transition control
    • Created comprehensive progressive mode E2E test suite (8 tests):
      • Explicit snapshot phase and atomic swap validation
      • Txid tracking behavior (Electric-only)
      • Multiple concurrent snapshots with deduplication
      • Incremental updates after swap
      • Predicate handling and resilience tests

    Bug Fixes:

    • Fixed type errors in test files
    • All 166 unit tests + 95 E2E tests passing
  • Updated dependencies [acb3e4f, 464805d, 2c2e4db, 15c772f]:

    • @tanstack/db@0.5.4

0.2.3

Patch Changes

  • Improve type of mutations in transactions (#854)

  • Updated dependencies [846a830, 8e26dcf]:

    • @tanstack/db@0.5.3

0.2.2

Patch Changes

  • Updated dependencies [99a3716]:
    • @tanstack/db@0.5.2

0.2.1

Patch Changes

  • Updated dependencies [a83a818]:
    • @tanstack/db@0.5.1

0.2.0

Minor Changes

  • Add timeout support to electricCollectionOptions matching strategies. You can now specify a custom timeout when returning txids from mutation handlers (onInsert, onUpdate, onDelete). (#798)

    Previously, users could only customize timeouts when manually calling collection.utils.awaitTxId(), but not when using the automatic txid matching strategy.

    Example:

    const collection = createCollection(
      electricCollectionOptions({
        // ... other config
        onInsert: async ({ transaction }) => {
          const newItem = transaction.mutations[0].modified
          const result = await api.todos.create({ data: newItem })
          // Specify custom timeout (in milliseconds)
          return { txid: result.txid, timeout: 10000 }
        },
      }),
    )

    The timeout parameter is optional and defaults to 5000ms when not specified. It works with both single txids and arrays of txids.

Patch Changes

  • Fix array txid handling in electric collection handlers. When returning { txid: [txid1, txid2] } from an onInsert, onUpdate, or onDelete handler, the system would timeout with TimeoutWaitingForTxIdError instead of properly waiting for all txids. The bug was caused by passing array indices as timeout parameters when calling awaitTxId via .map(). (#795)

  • Handle predicates that are pushed down. (#763)

  • Updated dependencies [243a35a, f9d11fc, 7aedf12, 28f81b5, 28f81b5, f6ac7ea, 01093a7]:

    • @tanstack/db@0.5.0

0.1.44

Patch Changes

0.1.43

Patch Changes

  • Updated dependencies [75470a8]:
    • @tanstack/db@0.4.19

0.1.42

Patch Changes

0.1.41

Patch Changes

  • Updated dependencies [49bcaa5]:
    • @tanstack/db@0.4.17

0.1.40

Patch Changes

0.1.39

Patch Changes

  • Updated dependencies [6738247]:
    • @tanstack/db@0.4.15

0.1.38

Patch Changes

  • Updated dependencies [970616b]:
    • @tanstack/db@0.4.14

0.1.37

Patch Changes

  • Updated dependencies [3c9526c]:
    • @tanstack/db@0.4.13

0.1.36

Patch Changes

0.1.35

Patch Changes

  • Updated dependencies [5566b26]:
    • @tanstack/db@0.4.11

0.1.34

Patch Changes

0.1.33

Patch Changes

0.1.32

Patch Changes

0.1.31

Patch Changes

  • feat: Add awaitMatch utility and reduce default timeout (#402) (#499)

    Adds a new awaitMatch utility function to support custom synchronization matching logic when transaction IDs (txids) are not available. Also reduces the default timeout for awaitTxId from 30 seconds to 5 seconds for faster feedback.

    New Features:

    • New utility method: collection.utils.awaitMatch(matchFn, timeout?) - Wait for custom match logic
    • Export isChangeMessage and isControlMessage helper functions for custom match functions
    • Type: MatchFunction<T> for custom match functions

    Changes:

    • Default timeout for awaitTxId reduced from 30 seconds to 5 seconds

    Example Usage:

    import { isChangeMessage } from '@tanstack/electric-db-collection'
    
    const todosCollection = createCollection(
      electricCollectionOptions({
        onInsert: async ({ transaction, collection }) => {
          const newItem = transaction.mutations[0].modified
          await api.todos.create(newItem)
    
          // Wait for sync using custom match logic
          await collection.utils.awaitMatch(
            (message) =>
              isChangeMessage(message) &&
              message.headers.operation === 'insert' &&
              message.value.text === newItem.text,
            5000, // timeout in ms (optional, defaults to 5000)
          )
        },
      }),
    )

    Benefits:

    • Supports backends that can't provide transaction IDs
    • Flexible heuristic-based matching
    • Faster feedback on sync issues with reduced timeout
  • Updated dependencies [6692aad]:

    • @tanstack/db@0.4.7

0.1.30

Patch Changes

  • prefix logs and errors with collection id, when available (#655)

  • Updated dependencies [dd6cdf7, c30a20b]:

    • @tanstack/db@0.4.6

0.1.29

Patch Changes

  • The awaitTxId utility now resolves transaction IDs based on snapshot-end message metadata (xmin, xmax, xip_list) in addition to explicit txid arrays, enabling matching on the initial snapshot at the start of a new shape. (#648)

  • Updated dependencies [7556fb6]:

    • @tanstack/db@0.4.5

0.1.28

Patch Changes

0.1.27

Patch Changes

  • Updated dependencies [32f2212]:
    • @tanstack/db@0.4.3

0.1.26

Patch Changes

  • Fix repeated renders when markReady called when the collection was already ready. This would occur after each long poll on an Electric collection. (#604)

  • Updated dependencies [51c6bc5, 248e2c6, ce7e2b2, 1b832ff]:

    • @tanstack/db@0.4.2

0.1.25

Patch Changes

  • Updated dependencies [8cd0876]:
    • @tanstack/db@0.4.1

0.1.24

Patch Changes

  • Refactor the main Collection class into smaller classes to make it easier to maintain. (#560)

  • Updated dependencies [2f87216, ac6250a, 2f87216]:

    • @tanstack/db@0.4.0

0.1.23

Patch Changes

  • Pull in the latest version of @electric-sql/client instead of pinning it (#572)

  • Updated dependencies [cacfca2]:

    • @tanstack/db@0.3.2

0.1.22

Patch Changes

  • Updated dependencies [5f51f35]:
    • @tanstack/db@0.3.1

0.1.21

Patch Changes

0.1.20

Patch Changes

  • Refactor of the types of collection config factories for better type inference. (#530)

  • Define BaseCollectionConfig interface and let all collections extend it. (#531)

  • Updated dependencies [b03894d, 3968087]:

    • @tanstack/db@0.2.5

0.1.19

Patch Changes

0.1.18

Patch Changes

  • Fixed a bug where a live query could get stuck in "loading" state, or show incomplete data, when an electric "must-refetch" message arrived before the first "up-to-date". (#532)

  • Updated dependencies [b162556]:

    • @tanstack/db@0.2.3

0.1.17

Patch Changes

  • fix AbortController re-initialization after a collection is garbage collected (#523)

0.1.16

Patch Changes

  • Updated dependencies [33515c6]:
    • @tanstack/db@0.2.2

0.1.15

Patch Changes

  • Updated dependencies [620ebea]:
    • @tanstack/db@0.2.1

0.1.14

Patch Changes

0.1.13

Patch Changes

  • Updated dependencies [cc4c34a]:
    • @tanstack/db@0.1.12

0.1.12

Patch Changes

  • Updated dependencies [b869f68]:
    • @tanstack/db@0.1.11

0.1.11

Patch Changes

0.1.10

Patch Changes

  • Updated dependencies [d64b4a8]:
    • @tanstack/db@0.1.9

0.1.9

Patch Changes

  • fix the handling of an electric must-refetch message so that the truncate is handled in the same transaction as the next up-to-date, ensuring you don't get a momentary empty collection. (#460)

  • fix disabling of gc by setting gcTime: 0 on the collection options (#463)

  • Updated dependencies [1c5e206, 4d20004, 968602e]:

    • @tanstack/db@0.1.8

0.1.8

Patch Changes

  • bump electric version (#454)

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

  • Add must-refetch message handling to clear synced data and re-sync collection data from server. (#412)

  • Export the AwaitTxIdFn type to ensure that building with types works correctly. (#398)

  • Updated dependencies [c90b4d8, 6c1c19c, 69a6d2d, 6250a92, 68538b4]:

    • @tanstack/db@0.1.4

0.1.3

Patch Changes

  • Updated dependencies [0cb7699]:
    • @tanstack/db@0.1.3

0.1.2

Patch Changes

  • Ensure that you can use optional properties in the select and join clauses of a query, and fix an issue where standard schemas were not properly carried through to live queries. (#377)

  • Updated dependencies [bb5d50e, 97b595e]:

    • @tanstack/db@0.1.2

0.1.1

Patch Changes

0.1.0

Minor Changes

  • 0.1 release - first beta 🎉 (#332)

Patch Changes

0.0.15

Patch Changes

  • Updated dependencies [6e8d7f6]:
    • @tanstack/db@0.0.33

0.0.14

Patch Changes

  • Updated dependencies [e04bd12]:
    • @tanstack/db@0.0.32

0.0.13

Patch Changes

  • Updated dependencies [3e9a36d]:
    • @tanstack/db@0.0.31

0.0.12

Patch Changes

  • Updated dependencies [6bdde55]:
    • @tanstack/db@0.0.30

0.0.11

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 TanStackDBError class - 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 instanceof checks 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 instanceof checks
    • 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 TanStackDBError class 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.

  • Updated dependencies [ced0657, dcfef51, 360b0df, 608be0c, 5260ee3]:

    • @tanstack/db@0.0.29

0.0.10

Patch Changes

0.0.9

Patch Changes

  • Updated dependencies [bec8620]:
    • @tanstack/db@0.0.27

0.0.8

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

0.0.7

Patch Changes

  • Add explicit collection readiness detection with isReady() and markReady() (#270)

    • Add isReady() method to check if a collection is ready for use
    • Add onFirstReady() method to register callbacks for when collection becomes ready
    • Add markReady() to SyncConfig interface for sync implementations to explicitly signal readiness
    • Replace onFirstCommit() with onFirstReady() for better semantics
    • Update status state machine to allow loading → ready transition for cases with no data to commit
    • Update all sync implementations (Electric, Query, Local-only, Local-storage) to use markReady()
    • Improve error handling by allowing collections to be marked ready even when sync errors occur

    This provides a more intuitive and ergonomic API for determining collection readiness, replacing the previous approach of using commits as a readiness signal.

  • Updated dependencies [1758eda, 20f810e]:

    • @tanstack/db@0.0.25

0.0.6

Patch Changes

0.0.5

Patch Changes

  • Updated dependencies [056609e]:
    • @tanstack/db@0.0.23

0.0.4

Patch Changes

  • Updated dependencies [aeee9a1]:
    • @tanstack/db@0.0.22

0.0.3

Patch Changes

  • Move Collections to their own packages (#252)

    • Move local-only and local-storage collections to main @tanstack/db package
    • Create new @tanstack/electric-db-collection package for ElectricSQL integration
    • Create new @tanstack/query-db-collection package for TanStack Query integration
    • Delete @tanstack/db-collections package (removed from repo)
    • Update example app and documentation to use new package structure

    Why?

    • Better separation of concerns
    • Independent versioning for each collection type
    • Cleaner dependencies (electric collections don't need query deps, etc.)
    • Easier to add more collection types moving forward
  • Updated dependencies [8e23322]:

    • @tanstack/db@0.0.21