Skip to content
Source
Sign inSign up
TanStack/query

fix(solid-query): don't re-trigger Suspense on background refetches #11230

Openbrenelz(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/11230/headopened

Showing 3 changed files with 157 additions and 23 deletions.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/solid-suspense-background-refetch.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/solid-query': patch
+---
+​
+Stop background refetches and cached-data mounts from re-triggering enclosing `<Suspense>` boundaries. Every observer update used to pass through the resource's Promise path, suspending the boundary for a microtask — which detached and re-inserted its DOM, restarting CSS animations and resetting focus/scroll/iframe state even though no fallback was ever painted. Queries now resolve synchronously when data is available, so Suspense only triggers on genuine initial loads.
86 additions and 1 deletionpackages/solid-query/src/__tests__/suspense.test.tsxModified
View file
@@ -384,7 +384,9 @@
expect(rendered.getByText('show')).toBeInTheDocument()
​
fireEvent.click(rendered.getByText('show'))
- expect(rendered.getByText('loading')).toBeInTheDocument()
+ // Cached data renders immediately without suspending; the mount refetch
+ // happens in the background
+ expect(rendered.getByText('data: 1')).toBeInTheDocument()
await vi.advanceTimersByTimeAsync(0)
expect(rendered.getByText('fetching: true')).toBeInTheDocument()
await vi.advanceTimersByTimeAsync(100)
@@ -895,4 +897,87 @@
expect(renders).toBe(2)
expect(rendered.queryByText('rendered')).toBeInTheDocument()