Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Angular: injectMutation skips pending state when triggered in constructor or ngOnInit

Aberta
#9,020 1 comentário 0 reações 2 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@benjavicente já está trabalhando nisso.

Desde 2/10/2026.

  • #9098 de @ThiloAschebrock — fechado sem integrar

Avaliação

Esta issue ainda não foi avaliada.

Descrição

Describe the bug

useMutation does indicate a pending state and remains idle until the mutation concludes if triggered in a Component constructor or ngOnInit lifecycle method, whereas triggering the mutation from ngAfterContentInit works as expected.

Your minimal, reproducible example

https://stackblitz.com/edit/angular-query-aqv6yuzm?file=src%2Fmain.ts

Steps to reproduce
  1. Refresh the page.
  2. Observe the state changes for the three mutations triggered in an Angular constructor, ngOnInit, or ngAfterContentInit.
  3. Notice that the two mutations triggered in the constructor and ngOnInit remain idle and do not indicate the pending state while the mutations are running.
Expected behavior

As a user, I expect the mutation to always indicate the correct idle and pending state, i.e., switch from idle to pending when a mutation has been triggered.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform
  • OS: Windows, maxOS,
  • Browser: Chrome, Edge
Tanstack Query adapter

angular-query

TanStack Query version

v5.74.3

TypeScript version

v5.6.3

Additional context

No response

Linguagem predominante
TypeScript
Estrelas
50.4k
Forks
4.3k
Merge médio
9h 42min
PRs com merge (30d)
590

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de TanStack/query

Todas as issues de TanStack/query

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.