Repository navigation
fix(solid-query): prevent suspense trigger with pre-cached data - #10053
shinseongsu wants to merge 2 commits into
Conversation
When using `refetchOnMount: false` with pre-cached data, the first `setQueryData` call would incorrectly trigger a Suspense fallback. This happened because the Proxy handler was calling `queryResource()` even when cached data was available. This fix ensures that: 1. The resource resolves immediately when data is already available, regardless of the `isLoading` state 2. The Proxy handler returns cached data directly when `isFetching` is false and data exists, avoiding unnecessary resource access Closes TanStack#9883
🦋 Changeset detectedLatest commit: c76a14f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
Caution Review failedThe pull request is closed. Walkthrough
🚥 Pre-merge checks | ✅ 4 | ❌ 1
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. |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
When using
refetchOnMount: falsewith pre-cached data, the firstsetQueryDatacall would incorrectly trigger a Suspense fallback. This happened because the Proxy handler was callingqueryResource()even when cached data was available.This fix ensures that:
isLoadingstateisFetchingis false and data exists, avoiding unnecessary resource accessCloses #9883
🎯 Changes
useBaseQuery.ts (line 263): Added || observerResult.data !== undefined condition to resolve the resource immediately when cached data exists, even if isLoading is true
useBaseQuery.ts (line 378-390): Modified the Proxy handler to check isFetching state before accessing queryResource(). When isFetching is false and data exists in either state or observerResult, return it directly without triggering Suspense
suspense.test.tsx: Added test case to verify that Suspense is never triggered when using refetchOnMount: false with pre-cached data, including initial render and subsequent setQueryData calls
result
Jan-19-2026.00-07-02.1.mp4
✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.