Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

已关闭
#2,036 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@alec-watts 已经在做这个了。

开始于 2026年10月5日。

  • #2037 来自 @alec-watts —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript
领域
databases

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
3.9k
派生
268
平均合并
1 天 3 小时
30 天内合并 PR
193

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TanStack/db 的其他 Issue

查看 TanStack/db 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。