[angular-query] Accessing `.data` kicks off the `CreateQueryOptions` function
Mantenedores costumam responder em até 1 dia
@benjavicente já está trabalhando nisso.
Desde 2/10/2026.
Avaliação
Esta issue ainda não foi avaliada.
Descrição
Describe the bug
I have a very simple use case when I do not have an error handler or loading indicator, so I am trying to create a query and save a reference to only the .data signal. I am not invoking the signal immediately, but saving a reference to only the signal.
ie: something = injectQuery(() => { ... }).data;
I am using a signal input as a part of my query key.
I wanted to make that signal input required, but in doing so, Angular started throwing a runtime error saying that the required input had no value. From the outside, I was always passing a value in for the input.
After I reverted the input back to not required, I noticed that the CreateQueryOptions function I was using for the signal was actually being invoked immdeiately upon construction of the component as well as after the input value was set.
I was able to narrow it down and realize that this only happens when I have .data on the end in order to store off the signal. I was only doing this for the sake of simplicity. Nothing else in my code needs a reference to the query itself. They only need access to the data signal, so that's what I stored off. I was not expecting that to immediately invoke the options, and thus access the signal input before it is initialized.
I can confirm that if I store the reference to the entire query (ie: without .data), then it works correctly (and I can add .required if I want to). It confuses me because either way, my template will access the signal "immediately" via either query.data() or data(). But I suppose that is actually when rendering, vs at construct time when I store off .data.
Is this just bad practice the way I am trying to do it, or would this actually be considered a bug?
Your minimal, reproducible example
Steps to reproduce
- Open the repro
- Look in the TanStack devtools and see that the "broken" example query ran twice. Once with
null, and once the correct result:
- Now, change
someInputto berequired(see commented out line where the input is defined) - You will get a runtime error in the console like so:
Expected behavior
I would expect that I can store off a reference to the .data signal whenever I want without it accessing signal inputs too soon.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: MacOS 14.5
- Browser: Edge
- Version: 125.0.2535.67
Tanstack Query adapter
angular-query
TanStack Query version
5.40.0
TypeScript version
5.3.3
Additional context
No response
- Linguagem predominante
- TypeScript
- Estrelas
- 50.4k
- Forks
- 4.3k
- Merge médio
- 13h 35min
- PRs com merge (30d)
- 442
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
-
QueryClient.isFetching and useIsFetching accept a fetchStatus filter and ignore itTalvez já em andamento @Apu-Emdad assumiu há 3 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)Talvez livre de novo @LeonxLJX assumiu há 43 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
-
solid-query 6.0.0-rc.5: onCacheEvent throws NotReadyError during a Solid 2 (rc.14+) transition landingTalvez já em andamento @UzumakiODZ assumiu há 2 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á 3 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 25/100
TanStack/query#12025 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
restoreQueries and persisterGc throw on malformed persisted entriesTalvez já em andamento @VGontier-cmd assumiu há 11 dias. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
Todas as issues de TanStack/query
Issues semelhantes
-
area:security documentation effort:S priority:P2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
Mantenedores costumam responder em até 1 dia
-
app:web meta:ops
Dificuldade 2/5 Meio dia Facilidade para iniciantes 78/100
osu-tournament-rating/otr#1113 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
typegoose/mongodb-memory-server#1040 ·
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 92/100