Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

DbClient.cleanup() cleans up a live query's source before the live query, logging an error on every SSR request

Aperta
#2,293 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
database

Direzione di ricerca

Start by locating DbClient.cleanup() and the live query cleanup registration it processes. Read the cleanup path alongside the source-cleaned error handling, then reproduce the issue using the supplied SSR example with chained useLiveQuery calls. Done means whole-client cleanup of those queries completes without logging the source-cleaned error.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

On the server, routerWithDbClient cleans up the request's DbClient once the render finishes. When one useLiveQuery reads from the collection another useLiveQuery returned (as in "Caching Intermediate Results"), every request logs:

[Live Query Error] Source collection 'live-query-2' was manually cleaned up while live query 'live-query-3' depends on it. Live queries prevent automatic GC, so this was likely a manual cleanup() call.

DbClient.cleanup() runs every registered live query cleanup at once, in creation order. The source query was created first, so it's cleaned up before the query that depends on it, and the dependent query reports an error. A single unchained live query cleans up silently.

Repro

@tanstack/db 0.15.1, @tanstack/react-db 0.5.11, React 19.3.1, Bun:

import { DbClient, DbProvider, collectionOptions, localOnlyCollectionOptions, useLiveQuery } from '@tanstack/react-db'
import { renderToString } from 'react-dom/server'

const todos = collectionOptions('todos', () =>
  localOnlyCollectionOptions({ id: 'todos', getKey: (t: { id: number }) => t.id, initialData: [{ id: 1 }, { id: 2 }] }),
)

function Todos() {
  const { collection: base } = useLiveQuery({ queryKey: ['base'], query: (q) => q.from({ todo: todos }) })
  const { data } = useLiveQuery({ queryKey: ['page', base.id], query: (q) => q.from({ todo: base }) })
  return <p>{data.length}</p>
}

const client = new DbClient()
client._setSsrServerCleanupEnabled(true) // what routerWithDbClient does on the server
renderToString(<DbProvider client={client}><Todos /></DbProvider>)
await client.cleanup() // logs the error above
Expected

A whole-client cleanup() tears the queries down without errors: either dependents before their sources, or no source-cleaned error for a query the same cleanup is about to clean up anyway.

Lingua principale
TypeScript
Stelle
4k
Fork
277
Merge medio
1g 4h
PR unite (30g)
212

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TanStack/db

Tutte le issue di TanStack/db

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.