perf(router-core): avoid async scaffolding for synchronous hooks - #8004
perf(router-core): avoid async scaffolding for synchronous hooks#8004Sheraff wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe client loading path now handles synchronous values without cancellation listeners, rechecks cancellation after ChangesClient-lane optimization
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The change keeps synchronous navigation hooks on a faster path while preserving cancellation for asynchronous hooks; no actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant RouterNavigation
participant beforeLoad
participant AbortSignal
participant RouteLoader
RouterNavigation->>beforeLoad: Execute synchronously
beforeLoad->>AbortSignal: Queue abort
RouterNavigation->>AbortSignal: Check after beforeLoad
RouterNavigation-->>RouteLoader: Skip loader when aborted
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 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 1ca28da
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version Preview1 package(s) bumped directly, 4 bumped as dependents. 🟩 Patch bumps
|
Bundle Size Benchmarks
The following scenarios have bundle-size changes compared with the baseline:
Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better. |
Merging this PR will degrade performance by 0.49%
|
Summary
waitFor's Promise, AbortController, and abort-listener scaffoldingbeforeLoadresultsWhy
Most client navigation hooks are typed as
Awaitable<T>, but the internal bridge treated every result as Promise-like. Even entirely synchronous navigation therefore allocated a wrapper Promise/controller, installed and removed an abort listener, and crossed an extra microtask boundary.This change makes the fast path part of the existing awaitable architecture: raw values remain raw, while actual Promises use the existing cancellation machinery. It intentionally does not add a generalized thenable adapter or a separate after-the-fact optimization layer.
Impact
Local A/B runs:
beforeLoadhooks: 0.6411 ms → 0.6223 ms (-2.9%)Full measurements and methodology are in
RESULT-optimization-promise-controller-context.md.Validation
git diff --check, and the affected bundle suite passedSummary by CodeRabbit
Performance
Bug Fixes
Tests