Render loop since v5.105.2 when placeholderData, or its select result, is not referentially stable
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 54/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- react, typescript
- Área
- backend-api-design, frontend
Línea de trabajo
Start with QueryObserver.createResult in queryObserver.ts, especially the placeholder data and select handling; the report points to the result notification path and compares behavior between v5.105.1 and v5.105.2. Reproduce with the linked example or add a regression test covering the listed useQuery and useQueries cases. Done when the results settle without repeated notifications while preserving the expected placeholder result.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
Since v5.105.2, a query that shows placeholderData can re-render in a loop until React throws "Maximum update depth exceeded". This happens when the placeholder result is a new reference each time the observer computes it, and the component renders again after mount (for example, because its parent re-renders). In v5.105.1, every case below settles.
| Case (the query never resolves) | useQuery |
useQueries |
|---|---|---|
placeholderData is a class instance created on every render |
settles | loops |
placeholderData is plain data whose content changes on every render |
settles | loops |
placeholderData is equal plain data created on every render, with a stable select that returns a Set |
loops | loops |
placeholderData is a stable object, with a stable select that throws for it |
loops | loops |
This looks like the same missing fixed point in QueryObserver.createResult as #12574, reached through placeholderData instead of keepPreviousData. The last row is not #12532: the select function is stable, and useQuery loops too.
Your minimal, reproducible example
https://stackblitz.com/github/jakubdrozdek/tanstack-query-placeholder-repro?file=src%2Fissue1.jsx
Steps to reproduce
- Open the example. Under "Issue 1", pick a case marked "loops".
- Click "re-render" once. The case shows "Maximum update depth exceeded".
- Set
@tanstack/react-queryto5.105.1inpackage.json. Every case settles.
The first case, for example:
class Row {
constructor(name) {
this.name = name
}
}
function Example() {
const [result] = useQueries({
queries: [{ queryKey: ['row'], queryFn: () => new Promise(() => {}), placeholderData: new Row('row') }],
})
return <p>{String(result.isPlaceholderData)}</p>
}
Expected behavior
The result settles, as in v5.105.1. A placeholder result that has not changed in meaning should not notify again only because its reference changed.
How often does this bug happen?
Every time
Platform
Not platform specific. Reproduced with React 19.2.8 in tests (Bun with happy-dom) and in the Vite example above.
Tanstack Query adapter
react-query
TanStack Query version
v5.108.1 (also v5.105.2 and v5.107.1; v5.105.1 is fine)
Additional context
On every render, useQuery and useQueries compute an optimistic result and then set the options again (#12230). replaceData cannot keep the previous reference for a class instance, a Set, or changed content, so each computation returns a new result and the observer notifies again. A select that throws creates a new error each time, with the same effect (queryObserver.ts:710 in v5.108.1).
- Lenguaje dominante
- TypeScript
- Estrellas
- 50.6k
- Forks
- 4.2k
- Merge medio
- 9 h 50 min
- PR fusionados (30 d)
- 310
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
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
TanStack/query#12466 · 1 comentario ·
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 77 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
-
select that throws for placeholderData brings back the selection of data removed by resetQueriesPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 56/100
Los mantenedores suelen responder en 1 día
-
useQueries: stable combine returns a stale result when a query updates before setQueries runsPosiblemente ocupada @sakaintp la tomó hace 1 día. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
TanStack/query#12626 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
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 78/100
fb55/htmlparser2#2579 ·
Los mantenedores suelen responder en 1 día
-
bug good first issue needs-review
Dificultad 1/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día
-
Add Module DB RulesAbiertodocumentation public
Dificultad 1/5 1-3 horas Aptitud para principiantes 68/100
midnightntwrk/umbradb#65 ·
Los mantenedores suelen responder en 2 días
-
area/channels kind/bug priority/medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nanocoai/nanoclaw#4501 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Docker images: plain X.Y.Z tag (e.g. 7.2.3) is never updated after the initial release buildAbiertoneeds verification
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 13 días