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 View on GitHub

Showing 3 changed files with 105 additions and 9 deletions.

x
0 of 3 viewed, 3 left
13 additions and 0 deletions.changeset/solid-query-key-switch-relay.mdAdded
View file
@@ -0,0 +1,13 @@
+---
+'@tanstack/solid-query': patch
+---
+​
+fix: compute the data once when a query switches to a key that is already
+cached. The read layer bumped its per-hook version signal on every cache
+event for its hash, including the observer events that `setOptions` emits
+from the options render effect, so the data projection (and `select`) ran
+a second time in a later flush and Solid's dev diagnostics reported
+`EFFECT_RELAY_TEAR`. The version now moves only on state events (`added`,
+`removed`, `updated`). `observerResultsUpdated`, which is how a query going
+stale by time reaches the adapter, bumps a separate signal that only
+`isStale` reads.
63 additions and 1 deletionpackages/solid-query/src/__tests__/useQuery-semantics.test.tsxModified
View file
@@ -6,7 +6,7 @@
// re-pointed separately.
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { fireEvent } from '@solidjs/testing-library'
-import { Errored, Loading, createSignal } from 'solid-js'
+import { Errored, Loading, createSignal, flush } from 'solid-js'
import { queryKey, sleep } from '@tanstack/query-test-utils'
import { QueryCache, QueryClient, useQuery } from '..'
import { renderWithClient } from './utils'
@@ -590,4 +590,66 @@
expect(rendered.getByText('v2')).toBeInTheDocument()