Skip to content

fix(solid-query): scope useMutation's cache subscription to the flight - #11325

Merged
brenelz merged 1 commit into
TanStack:solid-query-v6-prefrom
ryansolid:refactor/mutation-flight-subscription
Aug 29, 2026
Merged

fix(solid-query): scope useMutation's cache subscription to the flight#11325
brenelz merged 1 commit into
TanStack:solid-query-v6-prefrom
ryansolid:refactor/mutation-flight-subscription

Conversation

@ryansolid

Copy link
Copy Markdown

Summary

Alternative to #11324 — thanks @brenelz for catching the STRICT_READ_UNTRACKED diagnostic. Rather than untracking the mount-time client() read, this removes it: the diagnostic was pointing at a subscription that shouldn't exist at mount at all.

useMutation subscribed to the mutation cache at setup and held that subscription for the hook's whole life, but the listener only does anything between mutate and settle (activeMutation is null otherwise). The subscription now starts inside run, created against the same client the mutation is built on, and ends at the settle points (plus onCleanup for unmount mid-flight; a rapid re-mutate replaces the previous flight's listener).

What this buys over untrack:

  • Nothing reactive is read in the component body — the diagnostic goes away because the read is gone, not declared intentional.
  • Listener and mutation share a client by construction. Previously the subscription snapshotted the mount-time client while mutate built against the live one — a QueryClient swap could leave the listener on the old cache, silently dropping flight events.
  • Idle hooks hold no subscription. Every mounted useMutation used to hear every mutation-cache event forever just to filter it out; now cache events only fan out to hooks actually in flight.

Tests

Made with Cursor

The hook subscribed to the mutation cache at mount with a bare reactive
client() read — tripping Solid's STRICT_READ_UNTRACKED dev diagnostic
(reported by @brenelz in TanStack#11324) — and held that subscription for its
whole life even though the listener only matters between mutate and
settle. Rather than untracking the read, remove it: subscribe inside
run(), against the same client the mutation is built on, and unsubscribe
at the settle points (plus onCleanup for unmount mid-flight).

By construction: no reactive read at setup (nothing to untrack), the
listener and the mutation can never sit on different clients across a
QueryClient swap, and an idle useMutation holds no cache subscription —
mutation-cache events no longer fan out to every mounted hook.

Includes the TanStack#11324 regression test (no strict-read diagnostic on mount)
plus a listener-count test pinning the idle/flight/settled subscription
lifecycle.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

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: Pro Plus

Run ID: b08366f7-a91d-4435-ad54-3037604deef8

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

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.

@nx-cloud

nx-cloud Bot commented Aug 29, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit afe2bf1

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 4m 25s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 17s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-29 19:24:58 UTC

@pkg-pr-new

pkg-pr-new Bot commented Aug 29, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@11325

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@11325

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@11325

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@11325

@tanstack/preact-query-devtools

npm i https://pkg.pr.new/@tanstack/preact-query-devtools@11325

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@11325

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@11325

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@11325

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@11325

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@11325

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@11325

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@11325

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@11325

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@11325

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@11325

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@11325

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@11325

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@11325

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@11325

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@11325

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@11325

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@11325

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@11325

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@11325

commit: afe2bf1

@brenelz
brenelz merged commit 209f9f5 into TanStack:solid-query-v6-pre Aug 29, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants