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

Support persisted initialRender for Electric progressive collections

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

维护者通常 1 天内回复

@Jose10go 已经在做这个了。

开始于 2026年10月20日。

  • #2203 来自 @Jose10go —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
database

调研方向

Start with the network-first validation in @tanstack/db-sqlite-persistence-core and trace how @tanstack/electric-db-collection maps progressive sync mode to on-demand. Check the persistence and Electric collection tests for initial rendering and restored snapshots. Done means the reproduction no longer throws and a previously completed persisted snapshot can render while network synchronization continues.

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

描述

Description:

Persisted progressive electric collections should render its cached data after a hard refresh while network sync continues.

initialRender: {
  strategy: 'network-first',
  networkTimeoutMs: 0,
}

This throws for syncMode: 'progressive' because Electric translates it to 'on-demand', which the persistence wrapper rejects.
There is a documented restriction for on-demand collections. However, progressive collections eventually complete a full initial sync, so a previously completed, persisted snapshot should support this fallback.

Minimal reproduction

Versions: @tanstack/[email protected], @tanstack/[email protected].
Run this as an .mjs file with Node. No React, database, or running Electric server is needed to reproduce the configuration error.

import { electricCollectionOptions } from '@tanstack/electric-db-collection'
import { persistedCollectionOptions } from '@tanstack/db-sqlite-persistence-core'

persistedCollectionOptions({
  ...electricCollectionOptions({
    id: 'todos',
    syncMode: 'progressive',
    getKey: row => row.id,
    shapeOptions: {
      url: 'http://localhost:3000/v1/shape',
      params: { table: 'todos' },
    },
  }),
  persistence: {}, // Placeholder: throws before accessing persistence.
  initialRender: {
    strategy: 'network-first',
    networkTimeoutMs: 0,
  },
})

Produce Error: network-first initial rendering requires eager persistence syncMode

Expected behavior

For progressive collections with a previously completed persisted snapshot, allow initial rendering after local restoration, while network synchronization continues.

主要语言
TypeScript
星标
3.9k
派生
277
平均合并
18 小时 8 分钟
30 天内合并 PR
219

环境准备

从这里开始

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

TanStack/db 的其他 Issue

查看 TanStack/db 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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