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

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

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

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

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

Línea de trabajo

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.

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

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
4k
Forks
277
Merge medio
1 d 4 h
PR fusionados (30 d)
212

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.