Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

electric-db-collection: on-demand + persistence fails after relaunch with "Snapshot requests are not supported in full mode"

Abierto
#2,056 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@KyleAMathews ya está trabajando en esto.

Desde el 7/10/2026.

  • #2069 de @KyleAMathews — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
react-native, sqlite, typescript
Área
database

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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-collection 0.5.4. The same code is in 0.5.5 and on main.
  • @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

  1. Launch the app. A live query loads a subset. Rows arrive with tags. The library saves a resume state with requiresTagState: true.
  2. 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.

  1. On the new launch, the tag state from the first launch is gone (it was in memory), so retainsTagState is false. The saved resume state says requiresTagState: true, so needsFullSnapshot becomes true (~line 828).
  2. Because of that, the stream is created in full mode: log is not 'changes_only', and the offset is -1 (~line 872).
  3. The live query then calls loadSubset, and loadSubset still calls stream.requestSnapshot(...) (~line 248).
  4. The Electric client does not allow snapshots in full mode, so it throws Snapshot requests are not supported in full mode.
  5. 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.

Lenguaje dominante
TypeScript
Estrellas
3.9k
Forks
268
Merge medio
1 d 2 h
PR fusionados (30 d)
200

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TanStack/db

Todos los issues de TanStack/db

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.