fix(solid-query): untrack the client read in useMutation's cache subscription - #11324
fix(solid-query): untrack the client read in useMutation's cache subscription#11324brenelz wants to merge 1 commit into
Conversation
…cription useMutation subscribes to the mutation cache in the hook body via a bare client() memo read, which fires Solid's STRICT_READ_UNTRACKED diagnostic for any component that calls useMutation. Wrap it in untrack, matching how useBaseQuery guards the same body-scope read.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
|
View your CI Pipeline Execution ↗ for commit 34171ce
☁️ Nx Cloud last updated this comment at |
|
@ryansolid does this make sense? |
|
Good catch — the diagnostic is real, and your read of the semantics (one-time setup snapshot, matching I put up #11325 which removes the mount-time read instead of untracking it — the subscription becomes per-flight, created next to the |
Problem
Any component that calls
useMutationtriggers Solid'sSTRICT_READ_UNTRACKEDdev diagnostic on mount:The hook sets up its mutation-cache subscription in the component body with a bare
client()read —clientis acreateMemo, so this is a reactive read outside any tracking scope.Fix
Wrap the read in
untrack, matching howuseBaseQueryguards the same body-scope read (untrack(client)). The subscription is intentionally a one-time setup, so a snapshot read is the correct semantics.The other cache-reading hooks (
useIsMutating,useMutationState,useIsFetching) are unaffected:createCacheAggregatealready wraps theirsubscribe/readcallbacks inuntrackinternally.Test
Added a regression test that renders a bare
useMutationcomponent and asserts noSTRICT_READ_UNTRACKEDwarning is emitted. It fails without the fix and passes with it. Full solid-query suite passes (26 files, 345 tests, no type errors).🤖 Generated with Claude Code