fix(solid-query): don't bump the query version on observer-only cache events #12126
solid-query-v6-pre fromrefs/pull/12126/head·opened 🎯 Changes#
Closes #11903.
onCacheEvent bumped version for every cache event on the hook's hash. After a key switch, observer.setOptions in 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 as EFFECT_RELAY_TEAR.
version now moves only on state events (added, removed, updated). observerResultsUpdated still has to reach isStale, since it is how a query going stale by time is reported (two existing useQuery.test.tsx tests fail without it), so it bumps a separate signal that only isStale reads.
The new tests in useQuery-semantics.test.tsx pin one data-projection recompute per switch to a cached key (and back), counted through select: [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 log EFFECT_RELAY_TEAR, with identical rendered output. Not covered:
- a memo reading
query.isStalestill recomputes twice on a key switch; - the stale-key back-and-forth case from the issue comment (
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#
- I have followed the steps in the Contributing guide.
- I have tested code changes locally with
pnpm run test:pr, or these tests do not apply to this pull request. - I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.
🚀 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:
45b2045b-6df4-495d-8a09-25867f0b3aa9
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.-
S-jooyoung(GitHub profile, opens in a new tab) linked this to fix #11903
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 591e3cfafe22ec971a046bcf26b895b783c4db62
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