Persisted on-demand Electric collection enters error after a committed transaction waits across subset hydration

Fermée
#2,036 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@alec-watts y travaille déjà.

Depuis le 5/10/2026.

  • #2037 par @alec-watts — ouverte

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
45/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
typescript
Domaine
databases

Piste de recherche

Start by reading the transaction-boundary and hydration logic in applyBufferedSyncTransactionUnsafe, applyTransactionToCollection, loadSubset, and assertHydrationSequenceCurrent. Trace the reported sequence: a commit accepted at generation 0 is published after two subset hydrations. Done means accepted commits publish and persist consistently despite delayed publication, while genuinely open transactions crossing hydration cycles are still rejected; no reproduction or test file is named in the issue.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Observed behavior

With @tanstack/db-sqlite-persistence-core 0.4.3 and @tanstack/browser-db-sqlite-persistence 0.2.28, on-demand Electric collections enter a terminal error state during normal startup/subset loading:

InvalidPersistedCollectionConfigError: a persisted sync transaction cannot cross a hydration cycle

This surfaces as live-query source errors for jobs and documents.

Captured runtime sequence

Instrumentation around the source transaction boundaries, hydration generation changes, and publication captured this ordering for the jobs collection:

  1. Electric begin and commit both execute at hydration generation 0.
  2. Two persisted subset hydrations run, advancing the generation to 1 and then 2.
  3. applyBufferedSyncTransactionUnsafe calls applyTransactionToCollection for the already-committed transaction.
  4. The transaction has hydrationSequence=0, current generation=2, queuedBecauseHydrating=false, and internal=false. assertHydrationSequenceCurrent throws and the source enters error state.

The application did not keep the transaction open across these hydrations. Commit was accepted before the generation changed; publication happened later inside persistence scheduling.

Expected behavior

An accepted source commit should publish and persist in a consistent order with subsequent subset hydration, without invalidating the source merely because the persistence queue delayed publication. The existing rejection of genuinely open transactions crossing hydration cycles should remain.

Current source and related coverage

Current main still records the generation at external begin, validates it at commit, and validates it again at delayed publication. loadSubset schedules hydration through the same apply mutex and advances the generation.

Related: https://github.com/TanStack/db/pull/1911 covers a transaction beginning during hydration and committing after that hydration closes. This report concerns a commit accepted before later hydrations execute.

An isolated deterministic regression and fix are being investigated. No minimal standalone reproduction or tested upstream patch is attached yet. Disabling persistence for on-demand collections avoids the captured failure in the application; eager persistence remains enabled.

Langage dominant
TypeScript
Étoiles
4k
Forks
277
Merge moyen
1 j 11 h
PR mergées (30 j)
148

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de TanStack/db

Toutes les issues de TanStack/db

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.