Repository navigation
fix(query-core): refetch static queries that have no data - #12122
S-jooyoung wants to merge 1 commit into
Conversation
`refetchQueries` skips every static query, so an active query whose observers use `staleTime: 'static'` was not refetched after `resetQueries` cleared its data, nor by `invalidateQueries` after its first fetch failed. It was left without data and without a fetch. Only skip static queries in `refetchQueries` when they already have data, matching `isStaleByTime`, which treats a query without data as stale regardless of `staleTime`.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|

🎯 Changes
With
staleTime: 'static', callingresetQueriesclears the data but never refetches, so an active query stays inpendingwithfetchStatus: 'idle'. Same for a static query whose first fetch failed:invalidateQueriesdoesn't refetch it.refetchQueriesskips every static query, even one without data, whileisStaleByTimetreats a query without data as stale regardless ofstaleTime. This changes the filter to skip static queries only when they already have data. Static queries with data still aren't refetched.Added two tests in
queryClient.test.tsx(reset + invalidate after a failed fetch). Both fail before the change.Note: this PR description was drafted with AI assistance. The AI policy box is left unchecked for that reason.
✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Summary by CodeRabbit