Angular: whenStable() resolves while a mutation started with mutate() is still running
Mantenedores costumam responder em até 1 dia
@benjavicente já está trabalhando nisso.
Desde 2/10/2026.
- #11179 de @yogesh968 — fechado sem integrar
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 30/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Estagnada
- Stack de tecnologia
- angular, typescript
Direção de pesquisa
Comece pelo registro da tarefa pendente em packages/angular-query-experimental/src/inject-mutation.ts#L135-L146 e execute o caso de regressão em packages/angular-query-experimental/src/tests/pending-tasks.test.ts. Verifique se, após mutation.mutate(), ApplicationRef.whenStable() aguarda a conclusão da mutação e se as asserções de status e dados passam sem um tempo limite arbitrário.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- TypeScript
- Estrelas
- 50.5k
- Forks
- 4.2k
- Merge médio
- 8h 21min
- PRs com merge (30d)
- 621
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de TanStack/query
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)Talvez livre de novo @LeonxLJX assumiu há 54 dias e não há nenhum pull request aberto. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
TanStack/query#11358 · 2 comentários · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
useBaseQuery fetches the old query key when an <Activity> tree is revealedTalvez já em andamento @lazerg assumiu há 7 dias. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
Mantenedores costumam responder em até 1 dia
-
[query-broadcast-client-experimental] broadcastQueryClient: an `added` event overwrites a receiving query that has no data (e.g. in error) with the sender's empty stateTalvez já em andamento @lazerg assumiu há 8 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 25/100
Mantenedores costumam responder em até 1 dia
-
solid-query 6.0.0-rc.5: onCacheEvent throws NotReadyError during a Solid 2 (rc.14+) transition landingTalvez já em andamento @UzumakiODZ assumiu há 13 dias. Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 28/100
TanStack/query#12031 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Explicit gcTime schedules a GC timer during SSR, retaining the whole render in memoryTalvez já em andamento @AdzerKI assumiu há 14 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 25/100
TanStack/query#12025 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de TanStack/query
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
vekexasia/pi-extensible-workflows#374 ·
Mantenedores costumam responder em até 2 dias
-
documentation good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
Mantenedores costumam responder em até 1 dia
-
help wanted linux
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
GiuseppeBellamacina/downtime#19 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
scaleway/ultraviolet#7089 ·
Mantenedores costumam responder em até 2 dias
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Get-Concord-AI/concord-mcp#296 ·
Mantenedores costumam responder em até 1 dia