electric-db-collection: on-demand + persistence fails after relaunch with "Snapshot requests are not supported in full mode"
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #2069 @KyleAMathews による — マージ済み
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 68/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- react-native, sqlite, typescript
- 領域
- database
調査の方向性
Start with loadSubset in dist/esm/electric.js around line 248, then trace how needsFullSnapshot selects full mode around line 828. Ask the reporter to share their two-launch node:test reproduction, which exercises electricCollectionOptions, persistedCollectionOptions, and createExpoSQLitePersistence. Done means a relaunch with tagged rows no longer requests a snapshot in full mode and the collection becomes ready.
索引モデルが issue の本文から書いたものです。
説明
In short
An on-demand Electric collection with persistence works on the first app launch, but breaks on every launch after that. The second launch fails with:
Snapshot requests are not supported in full mode
After that error the collection stays in loading, and every live query on it fails until the local data is deleted.
It happens when the shape's rows have tags, which is the case when the shape's where has a subquery.
Versions
@tanstack/electric-db-collection0.5.4. The same code is in 0.5.5 and onmain.@electric-sql/client(the version 0.5.4 depends on)- Persistence:
persistedCollectionOptions+createExpoSQLitePersistence(React Native / Expo)
Setup
electricCollectionOptions({
syncMode: "on-demand",
shapeOptions: {
// the proxy adds a where with a subquery, for example:
// room_id IN (SELECT ... FROM permission_cache WHERE ...)
},
// ...
})
wrapped in persistedCollectionOptions(...).
Steps
- Launch the app. A live query loads a subset. Rows arrive with tags. The library saves a resume state with
requiresTagState: true. - Close the app, then open it again (a new JS process).
What goes wrong, step by step
Line numbers are from dist/esm/electric.js in 0.5.4.
- On the new launch, the tag state from the first launch is gone (it was in memory), so
retainsTagStateisfalse. The saved resume state saysrequiresTagState: true, soneedsFullSnapshotbecomestrue(~line 828). - Because of that, the stream is created in full mode:
logis not'changes_only', and the offset is-1(~line 872). - The live query then calls
loadSubset, andloadSubsetstill callsstream.requestSnapshot(...)(~line 248). - The Electric client does not allow snapshots in full mode, so it throws
Snapshot requests are not supported in full mode. - The throw comes before the stream starts, so the stream never starts and the collection never becomes ready.
So the library chooses full mode, then asks for something that full mode refuses.
Expected
When the stream is in full mode, loadSubset should not request a snapshot. It should wait until the full sync is ready, because the full log will contain the rows anyway.
Our workaround
We ship a small patch (about 35 lines) in loadSubset. When syncMode === 'on-demand' && needsFullSnapshot, it does not call requestSnapshot. It waits for the first markReady instead (it rejects if the initial sync calls markError, and resolves if the collection is aborted).
With the patch, the second launch works. One cost is left: every launch downloads the full shape again, because the tag state is not saved. Saving the tag state with the resume state may be the better fix. You know the design better than we do.
We are glad to open a PR with the patch, or share our test.
Test
We have a node:test test with two "launches". It uses the real electricCollectionOptions + persistedCollectionOptions + createExpoSQLitePersistence over node:sqlite, and a small fake Electric server that tags rows. It fails on 0.5.4 and passes with the patch. We can post it here.
Related
#811 has the same error text, in progressive mode.
- 主要言語
- TypeScript
- スター
- 3.9k
- フォーク
- 272
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 222
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/db のほかの issue
-
Electric progressive: apply and confirm changes to visible rows during the background full syncオープン
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 38/100
メンテナーはふだん 1 日以内に返信
-
Extend the Effect skipInitial oracle lane: ordered windows, includes, failures, and ordinary Effectsオープン
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
メンテナーはふだん 1 日以内に返信
-
Progressive collection live queries remain suspended after their requested subset finishes loading対応中かも @KyleAMathews が今日担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 5/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
affected/v17 affected/v18 area/frontend type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
umbraco/Umbraco-CMS#24186 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
better-auth/better-auth#11723 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area: docs difficulty: easy documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
Worker-Erstellung bricht langsame Git-Worktree-Checkouts nach 20 Sekunden ab対応中かも @KajoVanBuyten が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
AgentSystemLabs/agent-office#367 ·
メンテナーはふだん 1 日以内に返信