Skip to content

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

Open
S-jooyoung wants to merge 1 commit into
TanStack:solid-query-v6-prefrom
S-jooyoung:fix/solid-query-key-switch-relay
Open

S-jooyoung wants to merge 1 commit into
TanStack:solid-query-v6-prefrom
S-jooyoung:fix/solid-query-key-switch-relay

Conversation

@S-jooyoung

Copy link
Copy Markdown
Contributor

🎯 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).

… 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-bot

changeset-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 591e3cf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@tanstack/solid-query Patch
@tanstack/solid-query-devtools Patch
@tanstack/solid-query-persist-client Patch

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

@coderabbitai

coderabbitai Bot commented Oct 19, 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: 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.

This branch has not been deployed

No deployments
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.

1 participant