solid-query 6.0.0-rc.5: onCacheEvent throws NotReadyError during a Solid 2 (rc.14+) transition landing
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 28/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- typescript
- Bereich
- frontend
Rechercherichtung
Start with the reproduction test in the issue, run under both the prod and dev builds, to see the unhandled NotReadyError. The throw comes from the untracked read of defaultedOptions inside onCacheEvent in the solid-query useBaseQuery hook, so read that handler and the observer.options it could use instead. Done means the repro passes in both builds with no unhandled error and the third transition commits, and the existing solid-query tests still pass.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
With Solid 2 rc.14+ (solid-js / @solidjs/signals 2.0.0-rc.15), useBaseQuery's onCacheEvent can throw NotReadyError while a transition lands. The throw escapes unhandled, aborts the landing, and the next transition never commits.
The chain:
- A transition lands, and an unmounting
useQueryruns itsonCleanup:observer.destroy()→QueryCache.notify. - The notify reaches a sibling
useQueryon the same key that was created inside that (still held) transition. - Its
onCacheEventcomparesevent.query.queryHash === untrack(defaultedOptions).queryHash.defaultedOptionsis a memo born held, and since rc.14 an untracked read of such a node throwsNotReadyError(Solid 2 diagnostic A19, exception 1).
In an app with @solidjs/router this looks like a navigation that never finishes.
Your minimal, reproducible example
Inline below (vitest + jsdom; no app code). jsdom is needed because isServer is typeof window === "undefined", and without it the cache subscription is never created.
Steps to reproduce
vitest.config.mjs:
import { defineConfig } from "vitest/config";
const dev = process.env.MODE === "dev";
const conditions = dev ? ["development", "browser"] : ["browser"];
export default defineConfig({
test: {
pool: "forks",
environment: "jsdom",
server: { deps: { inline: [/solid-js/, /@solidjs/, /@tanstack\/solid-query/] } },
},
resolve: { conditions },
ssr: { resolve: { conditions, externalConditions: conditions } },
});
repro.test.mjs:
import { QueryClient, useQuery } from "@tanstack/solid-query";
import { createMemo, createRenderEffect, createRoot, createSignal, flush, onCleanup } from "solid-js";
import { expect, it } from "vitest";
const tick = () => new Promise((r) => setTimeout(r, 0));
it("query torn down on landing must not abort it for a sibling born in the transition", async () => {
const gates = [];
const releaseAll = async () => {
for (let i = 0; i < 6; i++) {
for (const open of gates.splice(0)) open();
await tick();
flush();
await tick();
}
};
const flight = (k) => (k > 0 ? new Promise((r) => gates.push(r)).then(() => k) : Promise.resolve(k));
const client = new QueryClient({ defaultOptions: { queries: { retry: false, gcTime: Infinity } } });
const [s, setS] = createSignal(0);
const shown = [];
const dispose = createRoot((done) => {
const screen = createMemo(() => {
const k = s();
const q = useQuery(() => ({ queryKey: ["repro"], queryFn: async () => "answer" }), () => client);
return () => (q.isSuccess ? k : -1);
});
const pending = createMemo(async () => flight(s()));
createRenderEffect(
() => [screen()(), pending()],
([k]) => { shown.push(k); },
);
return done;
});
flush();
await releaseAll();
setS(1); flush(); await tick();
setS(2); flush(); await releaseAll();
setS(3); flush(); await releaseAll();
expect(s()).toBe(3);
expect(shown.at(-1)).toBe(3);
dispose();
client.clear();
});
Run with MODE=prod NODE_ENV=production npx vitest run repro.test.mjs, or MODE=dev NODE_ENV=development for the dev build.
| patches applied | prod build | dev build |
|---|---|---|
| none | assertion fails (s() stays 2), unhandled NotReadyError |
same |
| adapter change below only | passes, no error | same |
| Solid fix from solidjs/solid#4089 only | assertion passes, NotReadyError still unhandled |
same |
| both | passes, no error | same |
We confirmed the source of the throw by temporarily wrapping untrack(defaultedOptions) in onCacheEvent with a try/catch, which caught NotReadyError on cache events during the landing.
Expected behavior
The test passes: onCacheEvent does not throw during a landing, and the third transition commits (s() === 3, last rendered value 3).
Possible fix
observer.options is what the committed render effect last passed to observer.setOptions, so it holds the hook's current hash in a plain object instead of the reactive graph:
- if (event.query.queryHash === untrack(defaultedOptions).queryHash || event.query.queryHash === latestHash) {
+ if (event.query.queryHash === observer.options.queryHash || event.query.queryHash === latestHash) {
With this change the reproduction passes in both builds. We have not run the solid-query test suite against it.
How often does this bug happen?
Every time
Platform
- Node v25.8.2, macOS; vitest 4.1.11, jsdom 29.1.1. The navigation hang also shows up in Chrome.
Tanstack Query adapter
solid-query
TanStack Query version
@tanstack/solid-query 6.0.0-rc.5 (@tanstack/query-core 5.101.4)
Additional context
solid-js2.0.0-rc.15 /@solidjs/signals2.0.0-rc.15. Not reproducible on rc.13, which has no throwing branch for untracked reads of held nodes.- Related Solid issue on the same landing path: solidjs/solid#4089. Fixing either side alone does not cover the other: the Solid fix hides the stuck transition, but the
NotReadyErrorfrom the adapter still escapes. - Possibly related: #11903 (a different symptom of the same
useBaseQueryrelay under Solid 2).
- Vorherrschende Sprache
- TypeScript
- Sterne
- 50.4k
- Forks
- 4.3k
- Ø Merge
- 13 Std. 35 Min.
- Gemergte PRs (30 T.)
- 442
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus TanStack/query
-
QueryClient.isFetching and useIsFetching accept a fetchStatus filter and ignore itEvtl. vergeben @Apu-Emdad hat das vor 4 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)Evtl. wieder frei @LeonxLJX hat das vor 44 Tagen übernommen, und es ist kein Pull Request offen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
TanStack/query#11358 · 2 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Explicit gcTime schedules a GC timer during SSR, retaining the whole render in memoryEvtl. vergeben @AdzerKI hat das vor 4 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 25/100
TanStack/query#12025 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
restoreQueries and persisterGc throw on malformed persisted entriesEvtl. vergeben @VGontier-cmd hat das vor 12 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
TanStack/query#11903 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
components-web-app/docs#260 ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 65/100
521xueweihan/HelloGitHub#4025 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
ctrf-io/playwright-ctrf-json-reporter#117 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
voidzero-dev/void#478 ·
Maintainer antworten meist innerhalb von 1 Tag