fix(router-core): dehydrate SSR match IDs with non-path encoding#6742
fix(router-core): dehydrate SSR match IDs with non-path encoding#6742
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds SSR match-ID encoding/decoding to prevent URL-shaped match IDs in serialized SSR state: server-side IDs are dehydrated (slashes replaced), client-side hydration decodes them before lookup and SPA-mode checks, and tests validate the transformations and hydration behavior. Changes
Sequence Diagram(s)sequenceDiagram
participant Server as Server (SSR)
participant Browser as Client (browser)
participant Router as Router runtime
Server->>Server: dehydrate match IDs\n(dehydrateSsrMatchId: '/' → '\0')
Server->>Browser: embed dehydrated router state\n(window.$_TSR)
Browser->>Browser: read local dehydratedRouter
Browser->>Browser: hydrate IDs\n(hydrateSsrMatchId: '\0' → '/')
Browser->>Router: perform hydration lookup using decoded IDs
Router-->>Browser: restore matches / skip load if already resolved
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
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)
Comment |
|
View your CI Pipeline Execution ↗ for commit a61b1be
☁️ Nx Cloud last updated this comment at |
Bundle Size Benchmarks
Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better. |
Summary
/with\0during dehydration and restore during hydrationdehydrateMatch+lastMatchId) so client-side navigation/matching hot paths stay unchangedTesting
CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:unit --outputStyle=stream --skipRemoteCache -- tests/hydrate.test.ts tests/ssr-match-id.test.tsCI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:types --outputStyle=stream --skipRemoteCacheCI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:eslint --outputStyle=stream --skipRemoteCacheFixes #6739
Summary by CodeRabbit
Bug Fixes
New Features
Tests