Skip to content
Source
Sign inSign up
TanStack/query

fix(solid-query): don't bump the query version on observer-only cache events #12126

OpenS-jooyoung(GitHub profile, opens in a new tab)wants to merge 1 commit intosolid-query-v6-pre fromrefs/pull/12126/headopened

🎯 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.isStale still recomputes twice on a key switch;
  • the stale-key back-and-forth case from the issue comment (staleTime: 0) still logs ABANDONED_FLIGHTS and EFFECT_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. 🦋 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
      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: 45b2045b-6df4-495d-8a09-25867f0b3aa9

      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.

Sign in to join this conversation.