Skip to content
Source
Sign inSign up
TanStack/query

fix(solid-query): avoid held options reads during cache notifications #12034

Mergedniukanen1(GitHub profile, opens in a new tab)merged 1 commit intosolid-query-v6-pre fromrefs/pull/12034/headmerged 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. 🦋 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
      NameType
      @tanstack/solid-queryPatch
      @tanstack/solid-query-devtoolsPatch
      @tanstack/solid-query-persist-clientPatch

      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

    2. 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.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ 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_status to false in 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.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    3. Could a maintainer please approve the pending GitHub Actions workflow runs for this PR when convenient? Thank you.

    4. Re-checked against solid-js / @solidjs/web / @solidjs/signals 2.0.0-rc.19, and against next@17d4d1b with signals built from source, using @tanstack/solid-query@6.0.0-rc.5 unpatched. The reproduction from #12031 still fails:

      Solidresultuncaught error
      2.0.0-rc.13passes (s() === 3)none
      2.0.0-rc.15s() stays 2NotReadyError
      2.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) as NotReadyError. The signals dev-mode check now re-throws it as a plain Error with that message. Code that catches only NotReadyError would therefore miss it in dev.

      With a guard in onCacheEvent that treats a throwing untrack(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 nor next has a change on the Solid side that removes the need for the adapter fix.

    5. niukanen1(GitHub profile, opens in a new tab)commented

      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.

    6. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 542eb5cdd45dd43d092b1694fd5e2af6dd5869c3

      CommandStatusDurationResult
      nx run-many --target=build --exclude=examples/*...✅ Succeeded24sView ↗
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded2m 51sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-10-31 04:17:25 UTC

    7. More templates

      @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@12034

      commit: 542eb5c

    8. brenelz(GitHub profile, opens in a new tab) approved these changes

      This looks like a good fix

    9. TkDodo merged this6bab31b

    10. TkDodo closed this

Sign in to join this conversation.