Repository navigation
fix(solid-query): don't bump the query version on observer-only cache events - #12126
S-jooyoung wants to merge 1 commit into
Conversation
… events `setOptions` in the options render effect emits observer events (`observerAdded`, `observerResultsUpdated`, ...) after a key switch. `onCacheEvent` bumped `version` for all of them, so the data projection ran a second time in a later flush and Solid's diagnostics reported EFFECT_RELAY_TEAR. Bump `version` only for state events (`added`, `removed`, `updated`). `observerResultsUpdated` is still how a query going stale by time reaches `isStale`, so it bumps a separate signal that only `isStale` reads. Closes TanStack#11903
🦋 Changeset detectedLatest commit: 591e3cf 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 |
|
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 configuration
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 |
🎯 Changes
Closes #11903.
onCacheEventbumpedversionfor every cache event on the hook's hash. After a key switch,observer.setOptionsin the options render effect emits observer events (observerAdded,observerOptionsUpdated,observerResultsUpdated), so the data projection ran a second time in a later flush. That second run is what Solid's diagnostics report asEFFECT_RELAY_TEAR.versionnow moves only on state events (added,removed,updated).observerResultsUpdatedstill has to reachisStale, since it is how a query going stale by time is reported (two existinguseQuery.test.tsxtests fail without it), so it bumps a separate signal that onlyisStalereads.The new tests in
useQuery-semantics.test.tsxpin one data-projection recompute per switch to a cached key (and back), counted throughselect:[2, 2, 2]before (observer + projection twice),[2, 2]after.Checked locally with
@solidjs/diagnostics@2.0.0-rc.13(not added to the repo): the cached and switch-back scenarios from the issue no longer logEFFECT_RELAY_TEAR, with identical rendered output. Not covered:query.isStalestill recomputes twice on a key switch;staleTime: 0) still logsABANDONED_FLIGHTSandEFFECT_RELAY_TEAR(same output before and after this change).Note: this PR description was drafted with AI assistance. The AI policy box is left unchecked for that reason.
✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact