-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
refactor(router-core): cache matched route branch alongside the rest of the route match #5882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(router-core): cache matched route branch alongside the rest of the route match #5882
Conversation
…of the route match
WalkthroughA new internal Changes
Sequence Diagram(s)sequenceDiagram
participant Router
participant ProcessedTree
participant MatchCache
participant findRouteMatch
participant buildRouteBranch
Router->>ProcessedTree: request match for path (fuzzy?)
ProcessedTree->>MatchCache: lookup key
alt cache hit (RouteMatch)
MatchCache-->>Router: RouteMatch (contains branch)
else cache miss
Router->>findRouteMatch: compute match
findRouteMatch->>buildRouteBranch: build branch from leaf->root
buildRouteBranch-->>findRouteMatch: branch (root->...->leaf)
findRouteMatch->>MatchCache: store RouteMatch | null
findRouteMatch-->>Router: RouteMatch | null
end
Router->>Router: derive matchedRoutes = match?.branch ?? [root]
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧠 Learnings (4)📚 Learning: 2025-10-08T08:11:47.088ZApplied to files:
📚 Learning: 2025-10-01T18:31:35.420ZApplied to files:
📚 Learning: 2025-10-01T18:30:26.591ZApplied to files:
📚 Learning: 2025-09-28T21:41:45.233ZApplied to files:
🧬 Code graph analysis (1)packages/router-core/src/router.ts (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (2)
Comment |
|
View your CI Pipeline Execution ↗ for commit 8030232
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/router-core/src/new-process-route-tree.ts(5 hunks)packages/router-core/src/router.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5402
File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21
Timestamp: 2025-10-08T08:11:47.088Z
Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.
Applied to files:
packages/router-core/src/router.tspackages/router-core/src/new-process-route-tree.ts
📚 Learning: 2025-10-01T18:30:26.591Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 5330
File: packages/router-core/src/router.ts:2231-2245
Timestamp: 2025-10-01T18:30:26.591Z
Learning: In `packages/router-core/src/router.ts`, the `resolveRedirect` method intentionally strips the router's origin from redirect URLs when they match (e.g., `https://foo.com/bar` → `/bar` for same-origin redirects) while preserving the full URL for cross-origin redirects. This logic should not be removed or simplified to use `location.publicHref` directly.
Applied to files:
packages/router-core/src/router.ts
📚 Learning: 2025-10-01T18:31:35.420Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 5330
File: e2e/react-start/custom-basepath/src/routeTree.gen.ts:58-61
Timestamp: 2025-10-01T18:31:35.420Z
Learning: Do not review files named `routeTree.gen.ts` in TanStack Router repositories, as these are autogenerated files that should not be manually modified.
Applied to files:
packages/router-core/src/router.tspackages/router-core/src/new-process-route-tree.ts
🧬 Code graph analysis (2)
packages/router-core/src/router.ts (1)
packages/router-core/src/root.ts (1)
rootRouteId(2-2)
packages/router-core/src/new-process-route-tree.ts (3)
packages/router-core/src/lru-cache.ts (2)
LRUCache(1-5)createLRUCache(7-74)packages/router-core/src/Matches.ts (1)
RouteMatch(118-175)packages/router-core/src/route.ts (2)
RouteLike(1968-1979)path(1551-1553)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test
- GitHub Check: Preview
…of the route match (TanStack#5882)
Summary by CodeRabbit