fix: accumulate all parent context#6070
Conversation
WalkthroughThis PR refactors context aggregation in the router load pipeline by introducing Changes
Sequence DiagramsequenceDiagram
participant Router as Router
participant BuildCtx as buildMatchContext
participant Execute as executeBeforeLoad
participant Loader as getLoaderContext
participant Commit as loadRouteMatch Commit
Router->>BuildCtx: buildMatchContext(matches, index)
Note over BuildCtx: Merge parent matches<br/>__routeContext +<br/>__beforeLoadContext
BuildCtx-->>Router: Aggregated context
Router->>Execute: executeBeforeLoad with parent context
Execute->>BuildCtx: buildMatchContext(exclude current beforeLoad)
BuildCtx-->>Execute: Parent context only
Execute->>Execute: beforeLoad pipeline
Note over Execute: Context merged after<br/>beforeLoad resolution
Execute-->>Router: Updated context
Router->>Loader: getLoaderContext(index)
Loader->>BuildCtx: buildMatchContext(all parent + current)
BuildCtx-->>Loader: Full accumulated context
Loader-->>Router: Loader context
Router->>Commit: Commit route match
Commit->>BuildCtx: buildMatchContext(inner, index)
BuildCtx-->>Commit: Merged context for commit
Note over Commit: Context consistency<br/>across nested routes
Commit-->>Router: Committed
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2)**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{js,ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
⏰ 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 (5)
Comment |
|
View your CI Pipeline Execution ↗ for commit c5e478b
☁️ Nx Cloud last updated this comment at |
| includeCurrentMatch: boolean = true, | ||
| ): Record<string, unknown> => { | ||
| const context: Record<string, unknown> = { | ||
| ...(inner.router.options.context ?? {}), |
There was a problem hiding this comment.
undefined is spreadable, we can skip creating an object here
| ...(inner.router.options.context ?? {}), | |
| ...(inner.router.options.context), |
fixes #6068
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.