solid-query 6.0.0-rc.5: useBaseQuery bumps its version signal on observerAdded/observerRemoved, remounting <Show> children in a loop on Solid 2 rc.14+
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 78/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- typescript
- Domínio
- frontend
Direção de pesquisa
Comece por packages/solid-query/src/useBaseQuery.ts na branch solid-query-v6-pre e inspecione onCacheEvent, especialmente como ele trata event.type. Adicione um teste de regressão baseado na reprodução que verifique se o filho é montado uma única vez; está concluído quando eventos exclusivos do observer não disparam mais o loop de remontagem.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Describe the bug
useBaseQuery's onCacheEvent (packages/solid-query/src/useBaseQuery.ts on solid-query-v6-pre) calls setVersion(v => v + 1) for every query-cache event whose queryHash matches, without looking at event.type. observerAdded, observerRemoved, observerOptionsUpdated and observerResultsUpdated do not change the query's state, but each one re-runs the result projection.
On Solid 2 rc.14+ this combines with a core issue (solidjs/solid#4540): a non-keyed <Show> gated on q.data remounts its children on every re-run. A child that calls useQuery with the same key adds an observer on mount → observerAdded → version bump → remount → new observer → … an infinite remount loop.
- solid-js rc.13 + solid-query 6.0.0-rc.5: 1 mount
- solid-js rc.20 + solid-query 6.0.0-rc.5: loop (21 mounts before the guard)
- solid-js next@215c365: loop
Steps to Reproduce
package.json: solid-js, @solidjs/web, @solidjs/signals 2.0.0-rc.20, @tanstack/solid-query 6.0.0-rc.5; dev @solidjs/vite-plugin 3.0.0-next.54, vitest 5.0.5, jsdom 30.1.2.
import { render } from "@solidjs/web";
import { QueryClient, QueryClientProvider, useQuery } from "@tanstack/solid-query";
import { Show } from "solid-js";
import { expect, it } from "vitest";
const wait = (ms: number) => new Promise((r) => setTimeout(r, ms));
it("a second observer mounted under a Show gated on the first one's data mounts once", async () => {
const client = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Number.POSITIVE_INFINITY } } });
let mounts = 0;
const options = () => ({ queryKey: ["k"], queryFn: () => wait(10).then(() => 1) });
function Child() {
mounts++;
if (mounts > 20) throw new Error("remount loop");
useQuery(options);
return <p>child</p>;
}
function Page() {
const q = useQuery(options);
return (
<Show when={q.data !== undefined}>
<Child />
</Show>
);
}
const el = document.createElement("div");
const dispose = render(() => (
<QueryClientProvider client={client}>
<Page />
</QueryClientProvider>
), el);
await wait(100);
dispose();
expect(mounts).toBe(1);
});
package.json
{
"name": "solid-query-repro",
"private": true,
"type": "module",
"scripts": { "test": "vitest run" },
"dependencies": {
"solid-js": "2.0.0-rc.20",
"@solidjs/web": "2.0.0-rc.20",
"@solidjs/signals": "2.0.0-rc.20",
"@tanstack/solid-query": "6.0.0-rc.5"
},
"devDependencies": {
"@solidjs/vite-plugin": "3.0.0-next.54",
"jsdom": "30.1.2",
"vitest": "5.0.5"
}
}
vitest.config.ts
import solid from "@solidjs/vite-plugin";
import { defineConfig } from "vitest/config";
export default defineConfig({
plugins: [solid()],
test: { environment: "jsdom" },
});
Expected behavior
Child mounts once.
Actual behavior
expected 21 to be 1 (the guard throws "remount loop").
Suggested fix
Bump version only for events that can change the result (added, removed, updated), not for observer* events. The core issue is the root cause; this avoids the trigger and an unnecessary projection re-run per observer mount/unmount.
Related: #11903, #12031 / #12034 (same function, different defects).
- Linguagem predominante
- TypeScript
- Estrelas
- 50.5k
- Forks
- 4.2k
- Merge médio
- 11h 2min
- PRs com merge (30d)
- 524
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á 60 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
-
[svelte-query] A result key first read after the query settled stays stale: the component's copy refreshes only on a change of an already-tracked keyTalvez já em andamento @lazerg assumiu há 2 dias. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 20/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á 14 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 livre de novo @UzumakiODZ assumiu há 19 dias e não há nenhum pull request aberto. 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
-
solid-query: EFFECT_RELAY_TEAR on Solid 2 when a query key changes — useBaseQuery relays the result through a version signal written from a render effectTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
TanStack/query#11903 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de TanStack/query
Issues semelhantes
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
formbricks/formbricks#9918 ·
Mantenedores costumam responder em até 1 dia
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
thecodacus/pithagoras#364 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
openclimatefix/quartz-frontend#823 ·
Mantenedores costumam responder em até 4 dias
-
area:agent-manager community needs-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 1 dia
-
`contacts.create` posts to `/audiences/undefined/contacts` when `audienceId` is undefinedTalvez já em andamento @RaphaelFakhri assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
resend/resend-node#1176 ·
Mantenedores costumam responder em até 1 dia