Repository navigation
fix(router): let a pending navigation finish when invalidate runs - #46
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 3:47 AM ET / 07:47 UTC (Revision 3). ClawSweeper reviewWhat this changesPreserve pending navigation during untargeted invalidation or revalidation, and retain invalidated data when the previous route moves into cache. Merge readiness✅ Ready for maintainer review This PR remains necessary because main still cancels a pending destination during untargeted refresh. Both prior findings are resolved, and no blocking correctness concern remains. Priority: P2 Review scores
Verification
How this fits togetherThe standalone UI router receives application routes, locations, and loading callbacks. It coordinates navigation and cached data, then exposes route state for applications to present. flowchart TD
A[Application navigation] --> C[Router transitions]
B[Refresh request] --> D[Compare match identities]
D --> C
C --> E[Component and data loading]
C --> F[Preserve cached invalidation]
E --> G[Published route state]
F --> G
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep navigation and history aligned while preserving invalidated cached data and explicit route-refresh semantics. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the trigger: start loading another match while one remains active, then call untargeted invalidate or revalidate; main cancels the destination run. This review did not execute a reproduction. Is this the best way to solve the issue? Yes, comparing match identities and caching the latest stored state repairs the concurrency defect without expanding the public API. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a17a88d49566. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles) |
invalidate() and revalidate() without a route id started a navigation of the active route, which aborted an in-flight navigation to a different destination. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
14e966d to
dcbc0c3
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
What Problem This Solves
Fixes: untargeted invalidate or revalidate can cancel a pending navigation and leave history on the destination while router state remains on the previous match.
User Impact
User impact: refreshing current route data while another match is loading no longer cancels that navigation, including transitions between two
loaderDepsidentities of the same route. Invalidated data remains stale when the previous active match moves into cache, so returning to it refetches as expected. Explicit route refresh behavior is unchanged.Why This Change Was Made
Untargeted refresh compares the live navigation's match identity with the active match identity. Cache transfer also re-reads the match store instead of reusing an earlier navigation snapshot, preserving invalidation that occurs while the destination loads.
Evidence
Validated at
1a24efa9ce742be23b6bc542f10c7f1a65cf637cwith Node 26.8.1 and pnpm 11.27.1:pnpm run test -- test/router-invalidate-pending.test.ts: 9 files and 58 tests passed.pnpm run check: format, build, typecheck, lint, all 58 tests, and packed-package import passed.git diff --check: passed./chat?session=oneto/chat?session=two, whereloaderDepsgives each location a distinct match identity.staleTimeregression defers routeb's component, invalidates whilebis pending, confirmsbstill finishes, then returns to routeaand confirms its loader refetches.The earlier built-package proof at
14e966dc7b3fcbdd60af919500ae762f27429d77also showed history, location, active route, and data settling on/bafter untargeted invalidate and revalidate during a two-route navigation.