Angular: whenStable() resolves while a mutation started with mutate() is still running
Los mantenedores suelen responder en 1 día
@benjavicente ya está trabajando en esto.
Desde el 2/10/2026.
- #11179 de @yogesh968 — cerrado sin fusionar
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 30/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- angular, typescript
Línea de trabajo
Comienza con el registro de la tarea pendiente en packages/angular-query-experimental/src/inject-mutation.ts#L135-L146 y ejecuta el caso de regresión en packages/angular-query-experimental/src/tests/pending-tasks.test.ts. Verifica que, después de mutation.mutate(), ApplicationRef.whenStable() espere a que la mutación se resuelva y que las aserciones de estado y datos pasen sin un tiempo de espera arbitrario.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
ApplicationRef.whenStable() resolves while a mutation started with mutate() is still running, so tests and SSR see the mutation as untouched.
injectMutation registers the Angular pending task from inside the observer subscription callback:
That callback is wrapped in notifyManager.batchCalls, so it runs in a later task than the mutate() call that started the mutation. In the window between the two there is no pending task, the application counts as stable, and whenStable() resolves right away. At that point the result signals have not been updated either, so status() still reads idle.
mutate() is fire and forget, so there is nothing else holding the application busy. mutateAsync() is not affected in the same way because the caller gets a promise back and can await it.
Your minimal, reproducible example
Failing test against main, added to packages/angular-query-experimental/src/__tests__/pending-tasks.test.ts:
it('should let whenStable wait for a mutation that was just triggered', async () => {
vi.useRealTimers()
const app = TestBed.inject(ApplicationRef)
const mutation = TestBed.runInInjectionContext(() =>
injectMutation(() => ({
mutationFn: (value: string) => sleep(5).then(() => value),
})),
)
TestBed.tick()
mutation.mutate('mutated')
await app.whenStable()
expect(mutation.status()).toBe('success')
expect(mutation.data()).toBe('mutated')
})
On current main this fails with expected 'idle' to be 'success'.
Steps to reproduce
- Set up a zoneless
TestBedwithprovideTanStackQuery. - Create a mutation with
injectMutationwhosemutationFntakes any real time. - Call
mutation.mutate(...). await ApplicationRef.whenStable().- Read
mutation.status().
Expected behavior
whenStable() should not resolve until the mutation has settled, the same way it already waits for queries once they have been reported. Right now the only way to make it wait is to insert an arbitrary setTimeout before calling it.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Reproduced with the repository test suite on Windows 11, Node 24.
Tanstack Query adapter
angular-query
TanStack Query version
5.101.4 (current main)
TypeScript version
5.9.3
Additional context
The same batching gap exists on the query side and is reported in #9981, #9910 and #10046. This issue is only about the mutation path, which those reports do not cover. I have a fix and a regression test ready and will open a PR.
- Lenguaje dominante
- TypeScript
- Estrellas
- 50.4k
- Forks
- 4.2k
- Merge medio
- 11 h 33 min
- PR fusionados (30 d)
- 421
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
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. 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: switching the queryClient accessor strands the new client's cache (subscription stays on the old observer)Posiblemente ocupada @MaNaN1803 la tomó hace 73 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
TanStack/query#11106 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Los mantenedores suelen responder en 1 día
-
setQueryData: NoInfer loses discriminated-union members when spreading a narrowed updater valuePosiblemente ocupada @iosayin la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Los mantenedores suelen responder en 1 día
-
setQueryData updater loses discriminated-union fields when spreading inferred NoInfer dataPosiblemente ocupada @boriskozak la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 68/100
TanStack/query#11794 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/query
Issues similares
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
lingdojo/kana-dojo#31665 · 1 comentario · 5 reacciones ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
-
Bug: lockTtlSeconds / lockHeartbeatIntervalSeconds accept non-positive and non-finite valuesPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
CopilotKit/CopilotKit#7618 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug ready-for-agent
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
sleeyax/paseo-plugins#112 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 4 días