fix(solid-router): hydration mismatch for ssr:false routes with pendingComponent#7608
fix(solid-router): hydration mismatch for ssr:false routes with pendingComponent#7608brenelz wants to merge 1 commit into
Conversation
…ngComponent Selective SSR routes render the pending component inside the suspense boundary on the server and skip the suspense fallback. On the client, the fallback was only skipped for ssr: 'data-only', so hydrating an ssr: false route rendered a fallback with no matching server markup, crashing dev hydration with "template is not a function". Skip the fallback only while actually hydrating (via solid-js sharedConfig.context) so client-side navigations and pure CSR keep showing the pending component while the match suspends. Fixes TanStack#7283 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
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 (5)
📝 WalkthroughWalkthroughThis PR fixes hydration mismatches for Solid Router ChangesHydration fix and E2E validation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
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 |
|
View your CI Pipeline Execution ↗ for commit 0cf3e3a
☁️ Nx Cloud last updated this comment at |
Fixes #7283
Problem
ssr: falseroutes with apendingComponentfail during dev hydration withtemplate is not a functionand never render the loaded component.Selective SSR routes render the pending component inside the suspense boundary on the server and skip the suspense fallback. On the client, #7266 only skipped the fallback for
ssr: 'data-only', so hydrating anssr: falseroute rendered a suspense fallback with no matching server markup — a hydration mismatch.Solution
The naive fix suggested in the issue (skipping the fallback for all selective SSR routes on the client too) regresses client-side navigation: the existing unit test
Router.preload="intent", pendingComponent renders during unresolved route loaderfails because the pending UI never shows when navigating to anssr: falseroute in the browser.Instead, skip the fallback only when it would conflict with server markup: on the server, and on the client while hydrating (detected via solid-js's
sharedConfig.context, which is only set during hydration). Client-side navigations and pure CSR keep their pending fallback. As a side effect this also restores the client-nav pending fallback fordata-onlyroutes, which #7266 had over-broadly removed.Testing
ssr: falseanddata-onlypending-component routes hydrate cleanly with zero browser errors and reach the loaded state.ssr: falseregression test mirroring the issue's MRE.Note: the e2e suite runs against a production build where the original bug didn't reproduce, so the new test guards the markup contract; the dev-mode failure was verified manually as described above.
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
ssr: falseandpendingComponent. Routes now skip the suspense fallback during server-side hydration while properly displaying the pending component on client-side navigation.Tests