SQLite persistence silently serializes Temporal values as {}, breaking hydration and subset queries
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 50/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- sqlite, typescript
- Área
- databases
Línea de trabajo
Start by reading the shared serializer in @tanstack/db-sqlite-persistence-core and tracing how SQLiteCorePersistenceAdapter.applyCommittedTx writes and restores values. Run the standalone reproduction linked in the issue with Node 22.13 or newer to confirm the failing cases. Done means Temporal values retain their types and values through rows, metadata, and replay, and the listed subset queries return the expected keys.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
- I've validated the bug against the latest version of DB packages
Describe the bug
@tanstack/db-sqlite-persistence-core silently stores Temporal.Instant and Temporal.PlainDate as {}. After reopening the SQLite database, the original values and types are lost. This also affects nested values, row metadata, collection metadata, and transaction replay payloads.
We encountered this in an Expo application. The reproduction uses the shared core with real SQLite on Node, so it requires no application code or Expo setup.
To reproduce
Reproduction: standalone test and instructions, on branch codex/repro-temporal-persistence in robertf224/db.
git clone --branch codex/repro-temporal-persistence https://github.com/robertf224/db.git
cd db/reproductions/temporal-persistence
pnpm install --frozen-lockfile
pnpm test
Use Node 22.13 or newer. The reproduction writes two different dates using SQLiteCorePersistenceAdapter.applyCommittedTx, closes and reopens the SQLite file, then checks hydration, metadata, replay, and subset queries. The command intentionally exits 1 because its assertions describe the expected behavior.
The persisted row JSON includes:
{
"instant": {},
"plainDate": {},
"nested": { "dates": [{}] }
}
For rows early (2026-01-02) and late (2026-01-03):
| Query | Expected keys | Actual keys |
|---|---|---|
plainDate = Temporal.PlainDate.from('2026-01-02') |
['early'] |
[] |
plainDate > Temporal.PlainDate.from('2026-01-02') |
['late'] |
[] |
ORDER BY plainDate ASC LIMIT 1 |
['early'] |
['late'] |
These results occur both without and with a persisted expression index installed. The query failures follow value corruption; this does not establish a separate compiler defect on correctly encoded Temporal values.
Verified result: 3 passing controls, 10 failing cases. Date round-tripping, a Date range predicate, and ISO string preservation pass. Temporal's own JSON.stringify returns ISO strings, so the {} loss occurs in persistence's recursive encoding before JSON serialization.
Expected behavior
Supported Temporal values should preserve their type and value across persistence, including nested values and metadata. Subset predicates, sorting, pagination, and persisted index expressions should agree with those values. If Temporal is unsupported, an explicit error would be preferable to silently destroying the data.
Environment
- macOS, Node 24.19.0, pnpm 11.19.0
@tanstack/db0.11.3@tanstack/db-sqlite-persistence-core0.4.3 (npm latest checked October 5, 2026)temporal-polyfill0.3.2- No patches; real file-backed SQLite through
node:sqlite
Additional context
The shared serializer recursively enumerates objects but has no Temporal handling. These Temporal instances have no enumerable own state, so different values collapse to the same empty object.
@tanstack/offline-transactions 1.0.61 already preserves these Temporal values when global constructors are registered; the reproduction includes that as a passing control. This report concerns the remaining SQLite persistence gap.
Native Temporal support or an extensible codec would help. A codec contract would need to cover row values, metadata, replay, query literals, and compatible index/comparison semantics. We currently wrap writes and reads in an application codec, but already-corrupted {} timestamps need cache invalidation or refetching.
- Lenguaje dominante
- TypeScript
- Estrellas
- 3.9k
- Forks
- 268
- Merge medio
- 1 d 4 h
- PR fusionados (30 d)
- 178
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TanStack/db
-
Persisted on-demand Electric collection enters error after a committed transaction waits across subset hydrationPosiblemente ocupada @alec-watts la tomó hace 1 día. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
TanStack/db#2036 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
Los mantenedores suelen responder en 1 día
-
useLiveInfiniteQuery commits an empty first render over a synchronously loaded collection (useLiveQuery doesn't)Posiblemente ocupada @KyleAMathews la tomó hace 1 día. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
TanStack/db#1972 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 45/100
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/db
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Comfy-Org/ComfyUI_frontend#20346 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
decentralized-identity/didwebvh-ts#203 ·
Los mantenedores suelen responder en 1 día
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
lingdojo/kana-dojo#31791 · 1 comentario · 5 reacciones ·
Los mantenedores suelen responder en 1 día
-
Telegram webhook: line breaks lost since switch to rich messagesPosiblemente ocupada @Kshot3000 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
github_actions security
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día