network-first: an eager Collection that last synced to zero rows stays loading offline

オープン
#2,284 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
sqlite, typescript
領域
backend, database

調査の方向性

Start with the persisted-readiness oracle at packages/db-sqlite-persistence-core/tests/persisted-readiness-oracle.test.ts and the readiness rules in docs/guides/sqlite-persistence.md. The issue calls for deciding what evidence makes an empty restore safe and which events invalidate it; review the linked discussions #2203 and #2263 for prior design context. Done means the law and its authority are stated, generated history reaches an empty completed restore, the parent fails, the change passes, and a hostile mutant still rejects a cold empty cache.

索引モデルが issue の本文から書いたものです。

説明

Summary

With initialRender: { strategy: 'network-first' }, an eager persisted Collection whose last sync produced zero rows stays loading offline. It becomes ready only when the sync adapter answers. An offline app therefore cannot show "no rows" for a Collection that is truly empty.

This is documented, intended behavior today. The guide (docs/guides/sqlite-persistence.md, "These rules keep ready meaningful") says:

An empty restore waits for the network. The Collection stays loading until the sync adapter answers, so an empty list always means "no rows". A Collection that last synced to zero rows also waits, because the restore cannot tell the two cases apart.

This issue asks whether the law should change, and how.

The problem

An empty restore has two causes that the wrapper cannot tell apart:

  1. A cold cache that never synced. Showing it as ready and empty is wrong.
  2. A cache whose last completed sync produced zero rows. Showing it as ready and empty is correct.

To open the second case offline, the wrapper needs evidence that a sync completed and that the empty row set is that sync's result.

Earlier proposal

#2203 proposed an adapter capability, isPersistedSnapshotComplete, that certifies a completed full snapshot with durable row-set evidence. That PR also covered Electric's progressive mode. #2263 solved the progressive case with per-demand coverage and no new adapter API, so #2203 was closed. #2203 did not address the eager empty case separately, and #2263 left it out of scope.

Questions for a design

  • Can the wrapper record "a full sync completed in this cache generation" itself, as #2263 does for each demand, without a new adapter API? For example, record it when the adapter calls markReady() after a complete snapshot and the rows are durably committed.
  • Which events end that evidence? Candidates are a truncate, a snapshot transaction, a cache-generation rotation, and a schema reset.
  • Does an eager source's markReady() always mean a complete snapshot, or only for some adapters?

Expected evidence for a change

The persisted-readiness oracle (packages/db-sqlite-persistence-core/tests/persisted-readiness-oracle.test.ts) owns this law. A change needs a stated law and authority, a generated history that reaches an empty completed restore, RED on the parent, GREEN after the change, and a hostile mutant that opens a cold empty cache.

Related

  • #2202, fixed by #2263.
  • #2102, design of safe offline subset reuse.
  • #2203, closed.
主要言語
TypeScript
スター
4k
フォーク
277
平均マージ
1日 7時間
マージ済み PR(30日)
170

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TanStack/db のほかの issue

TanStack/db の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。