Skip to content

improve(matches): update cached matches individually and build snapshots on read - #107

Merged
vincentkoc merged 3 commits into
mainfrom
refactor/router-cache-transitions
Nov 20, 2026
Merged

vincentkoc merged 3 commits into
mainfrom
refactor/router-cache-transitions

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Warming one more route made the router walk the existing cache, even when nobody was reading router state.

User Impact

Preloads and navigation update one match at a time. Callers still receive match lists in the same order, and previously read snapshots remain stable.

Why This Change Was Made

The store now replaces the active or pending match by key and updates individual cache entries. It builds the three snapshot arrays together on the next state read. Each notification still reaches state subscribers before match subscribers.

Evidence

  • A 256-route preload with no state subscriber went from 164,224 match-map entries visited to zero during preload, then 256 on the first state read. With a state subscriber attached, the preload sequence went from 164,224 visits to 131,584.
  • Baseline and branch agreed on membership, array and match identity, and ordered notifications over 4,800 mutations with nested batches and restarts.
  • All 45 focused subscription, loading, invalidation, and cancellation tests passed after integrating the subscriber-stop and cancelled-revalidation fixes from main. pnpm run check passed all 73 tests and package import validation. The public declarations matched the updated baseline byte for byte.

@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 12:17
@vincentkoc
vincentkoc requested a review from a team as a code owner November 20, 2026 12:17
…-transitions

* origin/main:
  improve(ci): prioritize the latest main commit (#109)
  improve(ci): stop the PR matrix after a package check fails (#105)
  improve(ci): avoid reinstalling pnpm after bootstrap (#101)
  fix(loading): ignore obsolete preload redirects after revalidation (#102)
  fix(router): honor a subscriber stopping a pending or redirecting navigation (#104)
  refactor(tests): verify load sharing and cache deadlines with smaller fixtures (#106)
  fix(history): resolve generated paths on startup with repeated base slashes (#103)
  improve(ci): run workflow lint when its inputs change (#100)

# Conflicts:
#	CHANGELOG.md
#	src/router.ts
…-transitions

* origin/main:
  fix(loading): allow preloading after a cancelled revalidation (#108)
  refactor(router): infer private loading and route catalog types (#111)
  fix(loading): keep a restarted router’s cached component (#110)

# Conflicts:
#	CHANGELOG.md
#	src/router.ts
@vincentkoc
vincentkoc merged commit 5acce87 into main Nov 20, 2026
10 of 11 checks passed
@vincentkoc
vincentkoc deleted the refactor/router-cache-transitions branch November 20, 2026 12:25
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