fix: preserve query behavior during hydration fetch#10467
fix: preserve query behavior during hydration fetch#10467SAY-5 wants to merge 1 commit intoTanStack:mainfrom
Conversation
When prefetchInfiniteQuery fails on the server and the promise streams
to the client, hydrate() calls query.fetch(undefined, ...) which drops
the behavior property. Without infiniteQueryBehavior, the retried fetch
stores raw data instead of the expected { pages, pageParams } structure.
Pass the query's existing behavior through to the fetch call so infinite
queries keep working after hydration.
Fixes TanStack#8825
|
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 (1)
📝 WalkthroughWalkthroughUpdated the hydration logic in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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 |
When prefetchInfiniteQuery fails on the server and the promise gets streamed to the client, hydrate() calls query.fetch(undefined, { initialPromise }) which drops the behavior property. Without infiniteQueryBehavior set, the retried fetch stores the raw response instead of wrapping it in the expected { pages, pageParams } structure, causing "Cannot read properties of undefined (reading 'length')" on the client.
The fix passes the query's existing behavior through to the fetch call so infinite queries retain their data processing pipeline after hydration.
Fixes #8825
Summary by CodeRabbit