fix(solid-query): avoid held options reads during cache notifications #12034
solid-query-v6-pre fromrefs/pull/12034/head·merged by TkDodo View on GitHub🎯 Changes#
Closes #12031.
Disposing a query during a transition landing can notify a sibling whose options memo has no committed value. Reading that memo untracked can throw NotReadyError on Solid 2 rc.14+ and interrupt the landing.
Keep the hash last applied by the options render effect in a plain field and match it alongside the latest computed hash. The observer's mutable options cannot serve as that snapshot because fetching and imperative refetching can advance them before the render effect runs (useBaseQuery's data pull and refetch both call observer.setOptions early).
Verified on solid-js 2.0.0-rc.15: the regression test from the issue fails on the previous code with the NotReadyError stack from the issue and passes with this change, in both development and production conditions. Also verified on solid-js/@solidjs/web/@solidjs/signals 2.0.0-rc.19 (devDependency bump, lockfile untouched): the same test fails on the unpatched code with the plain Error the rc.19 dev build re-throws ("Read of an unresolved async source after an await") and passes with this change. On the locked rc.13 runtime the suite is unaffected - the throwing branch does not exist there, and the full package suite shows the same results with and without this change (the pre-existing test-d type-check failures on this machine are identical in both runs).
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested this code locally with
pnpm run test:pr.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
- 1
Important
Review skipped#
Auto reviews are disabled on base/target branches other than the default branch.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
-
- Configuration used: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
a3f0f845-15d6-41da-a58e-68342dbb7ade
You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
- 🔍 Trigger review
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment `@coderabbitai help` to get the list of available commands.-
Could a maintainer please approve the pending GitHub Actions workflow runs for this PR when convenient? Thank you.
Re-checked against
solid-js/@solidjs/web/@solidjs/signals2.0.0-rc.19, and againstnext@17d4d1bwith signals built from source, using@tanstack/solid-query@6.0.0-rc.5unpatched. The reproduction from #12031 still fails:Solid result uncaught error 2.0.0-rc.13 passes ( s() === 3)none 2.0.0-rc.15 s()stays 2NotReadyError2.0.0-rc.19 / next@17d4d1bs()stays 2, last rendered value 2Error: Read of an unresolved async source after an \await`. …` (dev build)On rc.19 the development build no longer surfaces the throw from
untrack(defaultedOptions)asNotReadyError. The signals dev-mode check now re-throws it as a plainErrorwith that message. Code that catches onlyNotReadyErrorwould therefore miss it in dev.With a guard in
onCacheEventthat treats a throwinguntrack(defaultedOptions)as "no committed hash" (the same idea as this PR), the reproduction passes on rc.19 with no uncaught error. Neither the rc.19 release nornexthas a change on the Solid side that removes the need for the adapter fix.Thanks for checking rc.19. I ran this PR's transition-landing test against solid-js/@solidjs/web/@solidjs/signals 2.0.0-rc.19 locally (devDependency bump, lockfile untouched in the PR): it passes with the PR, and on the unpatched code it reproduces exactly what you describe, s() stays 2 and the dev build re-throws the untrack read as "Read of an unresolved async source after an
await". The guard in this PR takes the same idea one step earlier: onCacheEvent never reads the options memo at all, it compares against a plain lastAppliedHash field that the render effect updates, so there is no throw to catch in the first place.View your CI Pipeline Execution ↗ for commit 542eb5cdd45dd43d092b1694fd5e2af6dd5869c3
Command Status Duration Result nx run-many --target=build --exclude=examples/*...✅ Succeeded 24s View ↗ nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded 2m 51s View ↗
☁️ Nx Cloud last updated this comment at
2026-10-31 04:17:25UTCMore templates
- @tanstack/query-example-angular-auto-refetching
- @tanstack/query-example-angular-basic
- @tanstack/query-example-angular-basic-persister
- @tanstack/query-example-angular-devtools-panel
- @tanstack/query-example-angular-infinite-query-with-max-pages
- @tanstack/query-example-angular-optimistic-updates
- @tanstack/query-example-angular-pagination
- @tanstack/query-example-angular-query-options-from-a-service
- @tanstack/query-example-angular-router
- @tanstack/query-example-angular-rxjs
- @tanstack/query-example-angular-simple
- @tanstack/query-example-preact-simple
- @tanstack/query-example-solid-astro
- @tanstack/query-example-solid-basic
- @tanstack/query-example-solid-basic-graphql-request
- @tanstack/query-example-solid-default-query-function
- @tanstack/query-example-solid-offline
- @tanstack/query-example-solid-simple
- @tanstack/query-example-solid-start-streaming
- @tanstack/query-example-svelte-auto-refetching
- @tanstack/query-example-svelte-basic
- @tanstack/query-example-svelte-load-more-infinite-scroll
- @tanstack/query-example-svelte-optimistic-updates
- @tanstack/query-example-svelte-playground
- @tanstack/query-example-svelte-simple
- @tanstack/query-example-svelte-ssr
- @tanstack/query-example-svelte-star-wars
- @tanstack/query-example-react-algolia
- @tanstack/query-example-react-auto-refetching
- @tanstack/query-example-react-basic
- @tanstack/query-example-react-basic-graphql-request
- @tanstack/query-example-chat
- @tanstack/query-example-react-default-query-function
- @tanstack/query-example-react-devtools-panel
- @tanstack/query-example-eslint-legacy
- @tanstack/query-example-eslint-plugin-demo
- @tanstack/query-example-react-infinite-query-with-max-pages
- @tanstack/query-example-react-load-more-infinite-scroll
- @tanstack/query-example-react-nextjs
- @tanstack/query-example-react-nextjs-app-prefetching
- @tanstack/query-example-nextjs-suspense-streaming
- @tanstack/query-example-react-offline
- @tanstack/query-example-react-optimistic-updates-cache
- @tanstack/query-example-react-optimistic-updates-ui
- @tanstack/query-example-react-pagination
- @tanstack/query-example-react-playground
- @tanstack/query-example-react-prefetching
- @tanstack/query-example-react-react-native
- @tanstack/query-example-react-router
- @tanstack/query-example-react-rick-morty
- @tanstack/query-example-react-shadow-dom
- @tanstack/query-example-react-simple
- @tanstack/query-example-react-star-wars
- @tanstack/query-example-react-suspense
- @tanstack/query-example-lit-basic
- @tanstack/query-example-lit-pagination
- @tanstack/query-example-lit-ssr
- @tanstack/query-example-vue-2.6-basic
- @tanstack/query-example-vue-2.7-basic
- @tanstack/query-example-vue-basic
- @tanstack/query-example-vue-dependent-queries
- @tanstack/query-example-vue-nuxt3
- @tanstack/query-example-vue-persister
- @tanstack/query-example-vue-simple
@tanstack/angular-query-experimental
npm i https://pkg.pr.new/@tanstack/angular-query-experimental@12034@tanstack/eslint-plugin-query
npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@12034@tanstack/lit-query
npm i https://pkg.pr.new/@tanstack/lit-query@12034@tanstack/preact-query
npm i https://pkg.pr.new/@tanstack/preact-query@12034@tanstack/preact-query-devtools
npm i https://pkg.pr.new/@tanstack/preact-query-devtools@12034@tanstack/preact-query-persist-client
npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@12034@tanstack/query-async-storage-persister
npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@12034@tanstack/query-broadcast-client-experimental
npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@12034@tanstack/query-core
npm i https://pkg.pr.new/@tanstack/query-core@12034@tanstack/query-devtools
npm i https://pkg.pr.new/@tanstack/query-devtools@12034@tanstack/query-persist-client-core
npm i https://pkg.pr.new/@tanstack/query-persist-client-core@12034@tanstack/query-sync-storage-persister
npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@12034@tanstack/react-query
npm i https://pkg.pr.new/@tanstack/react-query@12034@tanstack/react-query-devtools
npm i https://pkg.pr.new/@tanstack/react-query-devtools@12034@tanstack/react-query-next-experimental
npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@12034@tanstack/react-query-persist-client
npm i https://pkg.pr.new/@tanstack/react-query-persist-client@12034@tanstack/solid-query
npm i https://pkg.pr.new/@tanstack/solid-query@12034@tanstack/solid-query-devtools
npm i https://pkg.pr.new/@tanstack/solid-query-devtools@12034@tanstack/solid-query-persist-client
npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@12034@tanstack/svelte-query
npm i https://pkg.pr.new/@tanstack/svelte-query@12034@tanstack/svelte-query-devtools
npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@12034@tanstack/svelte-query-persist-client
npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@12034@tanstack/vue-query
npm i https://pkg.pr.new/@tanstack/vue-query@12034@tanstack/vue-query-devtools
npm i https://pkg.pr.new/@tanstack/vue-query-devtools@12034commit:
542eb5cbrenelz(GitHub profile, opens in a new tab) approved these changes
This looks like a good fix
TkDodo merged this6bab31b
TkDodo closed this
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 542eb5cdd45dd43d092b1694fd5e2af6dd5869c3
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR