fix(query-core): set dataUpdatedAt for streamed queries that resolve before hydration (#10603)#10895
Conversation
…before hydration (TanStack#10603) When a dehydrated pending query's promise resolves synchronously during hydration (e.g., a React streamed query that completed before the client hydrated), the query correctly transitions to 'success' but dataUpdatedAt remained 0. This happened because PR TanStack#10444 removed the unnecessary query.fetch() call that previously set it. The fix sets dataUpdatedAt to Date.now() in the hydration path when: - The dehydrated query was pending (status: 'pending') - It resolved to have data (data !== undefined) - dataUpdatedAt is 0 (its default for pending queries) This applies to both new queries and existing queries in the cache.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR fixes a bug where ChangesStreamed Query Hydration dataUpdatedAt Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Fixes #10603
Summary
When a dehydrated pending query's promise resolves synchronously during hydration (e.g., a React streamed query that completed before the client hydrated), the query correctly transitions to
successbutdataUpdatedAtremained0.This happened because PR #10444 removed the unnecessary
query.fetch()call for already-resolved promises — which was correct for avoiding unnecessary fetch setup, but it also removed the side effect that setdataUpdatedAt.Fix
The fix sets
dataUpdatedAttoDate.now()in the hydration path when:status: 'pending')data !== undefined)dataUpdatedAtis0(its default for pending queries that never completed on the server)This applies to both:
elsebranch)ifbranch)Testing
Added two test cases:
dataUpdatedAt> 0 after hydrating a resolved pending querySummary by CodeRabbit
Bug Fixes
Tests