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

Angular: whenStable() resolves while a mutation started with mutate() is still running

Abierto
#11,176 1 comentario 0 reacciones 1 asignado Ver en GitHub

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
Área
frontend, testing

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

package: angular-query
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:

https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-mutation.ts#L135-L146

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
  1. Set up a zoneless TestBed with provideTanStackQuery.
  2. Create a mutation with injectMutation whose mutationFn takes any real time.
  3. Call mutation.mutate(...).
  4. await ApplicationRef.whenStable().
  5. 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

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/query

Todos los issues de TanStack/query

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.