Skip to content

perf(router): preserve pending locations without reading match snapshots - #117

Merged
vincentkoc merged 2 commits into
mainfrom
perf/navigation-location-snapshots
Nov 20, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
perf/navigation-location-snapshots

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Starting a navigation or joining one already in flight could copy every cached match merely to preserve the previous resolved URL.

User Impact

Navigation can update the requested URL without walking the cache. The previous resolved URL stays visible until the destination is published. State subscribers still receive full snapshots.

Why This Change Was Made

The match store already holds the resolved location. Its private location setter can preserve it directly when the caller only supplies a requested URL. Successful navigation still sets a resolved location explicitly, and an unmatched location still clears it.

Evidence

  • With 256 preloaded routes, 32 alternating navigations without state subscribers went from 32 snapshot builds and 8,222 cached entries copied to zero of either. The next public state read returned all 257 cached matches in one snapshot.
  • The baseline and branch produced the same 219 observations across 20 navigation cases covering joins, loader failure, component publication, stop, superseding navigation, and an unmatched URL. The comparison included location object identity and subscriber ordering.
  • Public router and type declarations matched byte for byte. The two added tests cover a join before the first route resolves and a join with an existing resolved route.
  • pnpm run check passed all 77 tests, formatting, build, type checking, lint, and packed-package import validation after integrating the pending-test cleanup from main.

@clawsweeper

clawsweeper Bot commented Nov 20, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@vincentkoc
vincentkoc marked this pull request as ready for review November 20, 2026 15:57
@vincentkoc
vincentkoc requested a review from a team as a code owner November 20, 2026 15:57
…ion-snapshots

* origin/main:
  refactor(tests): consolidate pending invalidation scenarios (#118)
  fix(loading): accept redirect records without a route location as data (#116)
  fix(loading): ignore a component import from before stop (#113)

# Conflicts:
#	test/router-invalidate-pending.test.ts
@vincentkoc
vincentkoc merged commit 9d13d62 into main Nov 20, 2026
10 of 11 checks passed
@vincentkoc
vincentkoc deleted the perf/navigation-location-snapshots branch November 20, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant