Explicit gcTime schedules a GC timer during SSR, retaining the whole render in memory
Los mantenedores suelen responder en 1 día
@AdzerKI ya está trabajando en esto.
Desde el 14/10/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, react, typescript
- Área
- frontend
Línea de trabajo
The bug is that an explicit finite gcTime schedules a real timer on the server, while the server default of Infinity does not. Start with the gist's gc-timer-retains-async-context.mjs reproduction and compare pending timers with default and finite. Pull request #12026 already targets this, so review it rather than starting a parallel fix. Done means no garbage-collection timer is scheduled on the server for any gcTime value.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
On the server, a query with an explicit finite gcTime (a regular client-side option) schedules a real setTimeout during SSR. The server default of Infinity is meant to prevent this, but an explicit gcTime bypasses it.
In Node, a pending timer keeps the render's async context (AsyncLocalStorage) alive until it fires. As a result, the entire render stays in memory: the HTML, the RSC payload, and the Request held by react-dom/server.
The timer serves no purpose. The request's QueryClient is discarded together with the response, so there is nothing left to garbage-collect.
Our case: Next.js 16, with a single useQuery({ gcTime: 24h }) in the root provider. Every render left behind a 24-hour timer and about 1.4 MB of retained memory. A heap snapshot of an idle replica showed 272 Request objects and 268 pending timers. Replicas grew until they hit the memory limit and were OOM-killed.
Your minimal, reproducible example
https://gist.github.com/AdzerKI/44081bf1d74a64d43ce651018ce2cba9
Steps to reproduce
- Save gc-timer-retains-async-context.mjs from the gist
- npm i @tanstack/query-core
- node --expose-gc gc-timer-retains-async-context.mjs default
- node --expose-gc gc-timer-retains-async-context.mjs finite
- Compare pendingTimers and rss in the output
Expected behavior
On the server, no garbage-collection timer should be scheduled for any gcTime value, the same as with the server default.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
OS: Linux
Runtime: Node.js 24.21.0 (server-side rendering, no browser involved)
Tanstack Query adapter
react-query
TanStack Query version
v5.104.2
TypeScript version
No response
Additional context
gcTime=default renders=2000 pendingTimers=0 external=2MB rss=119MB
gcTime=60000 renders=2000 pendingTimers=2000 external=1002MB rss=1069MB
- Lenguaje dominante
- TypeScript
- Estrellas
- 50.4k
- Forks
- 4.3k
- Merge medio
- 13 h 35 min
- PR fusionados (30 d)
- 442
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/query
-
QueryClient.isFetching and useIsFetching accept a fetchStatus filter and ignore itPosiblemente ocupada @Apu-Emdad la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)Quizá libre de nuevo @LeonxLJX la tomó hace 44 días y no hay ningún pull request abierto. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
TanStack/query#11358 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
solid-query 6.0.0-rc.5: onCacheEvent throws NotReadyError during a Solid 2 (rc.14+) transition landingPosiblemente ocupada @UzumakiODZ la tomó hace 2 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 28/100
TanStack/query#12031 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
restoreQueries and persisterGc throw on malformed persisted entriesPosiblemente ocupada @VGontier-cmd la tomó hace 12 días. 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 45/100
TanStack/query#11903 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/query
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
auth: agent-bearer --manager-call is told to use the MCP instance argument on an ambiguous managerAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
Los mantenedores suelen responder en 1 día
-
Lyric and ApostrophesAbiertobug module: playback
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
chthollyphile/folia-major#739 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
agilepathway/label-checker#773 · 2 comentarios ·
Los mantenedores suelen responder en 1 día