Skip to content

fix(router): final-review regressions, changeset, and byte recovery - #7883

Merged
Sheraff merged 3 commits into
fix-router-core-lane-match-loaderfrom
fix-lane-loader-review-regressions
Jul 23, 2026
Merged

fix(router): final-review regressions, changeset, and byte recovery#7883
Sheraff merged 3 commits into
fix-router-core-lane-match-loaderfrom
fix-lane-loader-review-regressions

Conversation

@Sheraff

@Sheraff Sheraff commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #7805 — implements the outcomes of the final review pass before partner testing.

Regressions vs main, fixed (each pinned test-first, red without the fix)

  1. History-subscription leak on router provider unmount (all three adapters). main unconditionally unsubscribed; the lane branch dropped that in fix(router-core): complete lane match loader rewrite #7858 — a discarded router kept loading on back/forward as a zombie, with acks that never resolve. React now returns the unsubscribe unconditionally (fewer bytes than the previous dev-only gate), Solid uses onCleanup, Vue uses onUnmounted. Pinned by new transitioner-remount tests in each adapter (unmount → history change → no load; remount with the same router → exactly one load per push).
  2. Double-click same-destination restarted loaders. main joined the in-flight load; the branch aborted the flights before the new lane's donor lookup ran, so every beforeLoad/loader re-ran. Same-location navigations now join the in-flight transaction (_dedupe flag from commitLocation's same-location branch). Reloads, invalidate(), and same-location redirects keep restart semantics. The headless no-subscriber fallback load moved inside the history-commit branch so headless same-location commits don't double-load. One existing pin re-adjusted: the reentrant onLeave navigation now fires onEnter exactly once instead of a suppressed enter plus a spurious onStay.
  3. Cache/committed same-id aliasing. commitMatches retention was keyed on the rendered prefix only, so _cache could retain an older generation of a beyond-boundary match while _committed held a newer one — and the cache-first planning lookup would silently present the stale data. Retention now also excludes same-id settled successes anywhere in the new lane; the "hidden terminal suffix must not evict a newer preload" contract stays intact.
  4. Mask-state same-location dedup. _getUserHistoryState stripped __tempLocation/__tempKey, so masked↔real same-href navigations skipped the history commit and never wrote/cleared mask state. The mask payloads now participate in the comparison, matching main's isSameState.

Deliberately not fixed here (follow-up, per review discussion): concurrent loader-redirect ordering (temporally-first vs shallowest-first) — that logic is being redone separately.

Changeset

Adds the missing release changeset for the four router packages (patch, following the repo's precedent), enumerating every removed/changed public API surface with migration hints: RouterState.{loadedAt,isTransitioning,statusCode,redirect}, RouteMatch.fetchCount/'redirected' status/globalNotFound, the removed RouterCore members, server-only headers(), StartTransitionFn signature, and the 30min→5min gcTime defaults.

Byte recovery

The rewrite's start-scenario gzip regression is compression shape, not code mass (bundles are 3–4 KB smaller minified-raw than main). Merging rendered-matches.ts, route-chunks.ts, and hydrate.ts into load-client.ts lets gzip share dictionary context across what were separate module boundaries:

scenario before after
react-start.minimal +609 B vs merge-base +423 B
react-start.full +508 B +372 B
solid-start.minimal +481 B +375 B
solid-start.deferred-hydration +483 B +379 B

All plain router and vue scenarios remain net-negative vs main; hydration still tree-shakes fully out of non-Start bundles (verified raw-byte-identical guards). Code moved verbatim with comments; hydration lives under a banner at the end of load-client.ts.

Test-count re-pins

store-updates-during-navigation (solid + vue): 7 exact-count pins re-adjusted. The published store-update sequences were captured and verified byte-identical before/after these changes — the counts only moved because a one-microtask timing shift relocates the tests' waitFor-sampled window boundary. 5 of 7 counts decreased.

Validation

  • All 9 package unit suites green, uncached, with react-router tested against a rebuilt router-core dist
  • test:types matrix green (TS 5.5–5.9) for router-core + all three adapters
  • Bundle-size measured per scenario with the local harness against the CI-reproducible merge-base baseline

🤖 Generated with Claude Code

Fixes the regressions vs main found in the final review of #7805:

- restore history-subscription cleanup on router provider unmount in all
  three adapters (react returns the unsubscribe unconditionally, solid
  uses onCleanup, vue uses onUnmounted), pinned by new
  transitioner-remount tests — a discarded router could previously keep
  loading on back/forward as a zombie
- same-destination navigations now join the in-flight transaction
  instead of aborting and restarting it (double-click no longer reruns
  loaders); reloads and same-location redirects keep restart semantics
- commitMatches cache retention can no longer resurrect a
  one-generation-old loaderData when a newer committed success exists
  for the same match id
- same-location dedup keeps __tempLocation/__tempKey so masked vs real
  same-href navigations commit their state again

Adds the missing release changeset enumerating the removed/changed
public API with migration hints.

Byte recovery: merges rendered-matches.ts, route-chunks.ts and
hydrate.ts into load-client.ts so the client bundle shares gzip
dictionary context across what were separate module boundaries
(-104..-186 gzip B per start scenario; plain router scenarios remain
net-negative vs main and hydration still tree-shakes out of them).

The solid/vue store-update-count pins were re-adjusted after verifying
the published update sequences are byte-identical: the counts only
shifted because a one-microtask timing change moves the tests'
waitFor-sampled window boundary (5 of 7 counts decreased).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1077a7cf-8324-4346-bde3-19d9710d11b8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-lane-loader-review-regressions

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 33588d1

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 13m 54s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 36s View ↗

☁️ Nx Cloud last updated this comment at 2026-07-23 13:33:17 UTC

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

4 package(s) bumped directly, 19 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/react-router 1.170.18 → 1.170.19 Changeset
@tanstack/router-core 1.171.15 → 1.171.16 Changeset
@tanstack/solid-router 1.170.18 → 1.170.19 Changeset
@tanstack/vue-router 1.170.17 → 1.170.18 Changeset
@tanstack/react-start 1.168.32 → 1.168.33 Dependent
@tanstack/react-start-client 1.168.16 → 1.168.17 Dependent
@tanstack/react-start-rsc 0.1.31 → 0.1.32 Dependent
@tanstack/react-start-server 1.167.22 → 1.167.23 Dependent
@tanstack/router-cli 1.167.21 → 1.167.22 Dependent
@tanstack/router-generator 1.167.21 → 1.167.22 Dependent
@tanstack/router-plugin 1.168.23 → 1.168.24 Dependent
@tanstack/router-vite-plugin 1.167.23 → 1.167.24 Dependent
@tanstack/solid-start 1.168.32 → 1.168.33 Dependent
@tanstack/solid-start-client 1.168.16 → 1.168.17 Dependent
@tanstack/solid-start-server 1.167.22 → 1.167.23 Dependent
@tanstack/start-client-core 1.170.14 → 1.170.15 Dependent
@tanstack/start-plugin-core 1.171.24 → 1.171.25 Dependent
@tanstack/start-server-core 1.169.17 → 1.169.18 Dependent
@tanstack/start-static-server-functions 1.167.19 → 1.167.20 Dependent
@tanstack/start-storage-context 1.167.17 → 1.167.18 Dependent
@tanstack/vue-start 1.168.31 → 1.168.32 Dependent
@tanstack/vue-start-client 1.167.19 → 1.167.20 Dependent
@tanstack/vue-start-server 1.167.22 → 1.167.23 Dependent

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: 6c123eeeff40
  • Measured at: 2026-07-23T13:20:25.666Z
  • Baseline source: history:edf55759d8e9
  • Dashboard: bundle-size history

The following scenarios have bundle-size changes compared with the baseline:

Scenario Current (gzip) Delta vs baseline Initial gzip Raw Brotli Trend
react-router.minimal 87.38 KiB +36 B (+0.04%) 87.25 KiB 269.83 KiB 76.16 KiB ▁▁▁▁▁▁▁▁▁▁▁█
react-router.full 91.16 KiB +96 B (+0.10%) 91.02 KiB 281.84 KiB 79.43 KiB ▁▁▁▁▁▁▁▁▁▁▁█
solid-router.minimal 35.09 KiB -448 B (-1.23%) 34.96 KiB 100.60 KiB 31.68 KiB ███████████▁
solid-router.full 40.18 KiB -416 B (-1.00%) 40.05 KiB 115.83 KiB 36.21 KiB ███████████▁
vue-router.minimal 52.37 KiB -641 B (-1.18%) 52.24 KiB 143.76 KiB 47.16 KiB ███████████▁
vue-router.full 58.34 KiB -613 B (-1.02%) 58.21 KiB 162.54 KiB 52.45 KiB ███████████▁
react-start.minimal 102.40 KiB +423 B (+0.41%) 102.26 KiB 318.95 KiB 88.92 KiB ▁▁▁▁▁▁▁▁▁▁▁█
react-start.deferred-hydration 103.14 KiB +424 B (+0.40%) 102.28 KiB 320.32 KiB 89.56 KiB ▁▁▁▁▁▁▁▁▁▁▁█
react-start.full 105.73 KiB +372 B (+0.34%) 105.59 KiB 328.95 KiB 91.70 KiB ▁▁▁▁▁▁▁▁▁▁▁█
react-start.rsbuild.minimal 100.07 KiB +401 B (+0.39%) 99.90 KiB 313.40 KiB 86.36 KiB ▁▁▁▁▁▁▁▁▁▁▁█
react-start.rsbuild.minimal-iife 100.47 KiB +398 B (+0.39%) 100.30 KiB 314.33 KiB 86.66 KiB ▁▁▁▁▁▁▁▁▁▁▁█
react-start.rsbuild.full 103.41 KiB +529 B (+0.50%) 103.24 KiB 323.54 KiB 89.02 KiB ▁▁▁▁▁▁▁▁▁▁▁█
solid-start.minimal 49.97 KiB +375 B (+0.74%) 49.84 KiB 148.60 KiB 44.38 KiB ▁▁▁▁▁▁▁▁▁▁▁█
solid-start.deferred-hydration 53.24 KiB +379 B (+0.70%) 49.90 KiB 156.64 KiB 47.31 KiB ▁▁▁▁▁▁▁▁▁▁▁█
solid-start.full 55.28 KiB -141 B (-0.25%) 55.15 KiB 164.39 KiB 48.93 KiB ███████████▁
vue-start.minimal 70.75 KiB -284 B (-0.39%) 70.62 KiB 201.64 KiB 62.84 KiB ███████████▁
vue-start.full 74.71 KiB -327 B (-0.43%) 74.58 KiB 214.25 KiB 66.17 KiB ███████████▁

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.

@pkg-pr-new

pkg-pr-new Bot commented Jul 23, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@7883

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@7883

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@7883

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@7883

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@7883

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@7883

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@7883

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@7883

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@7883

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@7883

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@7883

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@7883

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@7883

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@7883

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@7883

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@7883

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@7883

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@7883

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@7883

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@7883

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@7883

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@7883

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@7883

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@7883

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@7883

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@7883

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@7883

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@7883

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@7883

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@7883

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@7883

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@7883

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@7883

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@7883

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@7883

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@7883

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@7883

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@7883

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@7883

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@7883

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@7883

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@7883

commit: 33588d1

@nx-cloud nx-cloud Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud has identified a possible root cause for your failed CI:

We classified this failure as an environment issue rather than a code regression. The failing project (@tanstack/router-devtools-core) is not touched by this PR, and the error is a 5-second import hang — not a module-not-found error that would be expected if a deleted router-core file were a missing dependency. This points to a transient infrastructure stall (e.g. Vite transform timeout) unrelated to our changes.

No code changes were suggested for this issue.

Trigger a rerun:

Rerun CI

Nx Cloud View detailed reasoning on Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

@codspeed-hq

codspeed-hq Bot commented Jul 23, 2026

Copy link
Copy Markdown

Merging this PR will regress 6 benchmarks

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 13 improved benchmarks
❌ 6 regressed benchmarks
✅ 161 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem server error-paths unmatched (react) 270.5 KB 557.7 KB -51.49%
Memory mem server error-paths not-found (vue) 330.5 KB 488 KB -32.27%
Simulation ssr server-fn during document ssr (react) 64 ms 66.8 ms -4.14%
Memory mem server error-paths not-found (react) 244.1 KB 254.2 KB -4%
Simulation client-nested-params navigation loop (vue) 150.3 ms 156.2 ms -3.73%
Simulation ssr global-mw server-fn (solid) 57.6 ms 59.6 ms -3.32%
Memory mem server request-churn (react) 810.6 KB 482.4 KB +68.03%
Memory mem client unique-location-churn (solid) 527 KB 341.8 KB +54.22%
Memory mem server error-paths redirect (solid) 362.4 KB 282.2 KB +28.41%
Simulation ssr server-fn not-found (solid) 70.1 ms 61.9 ms +13.21%
Simulation ssr server-fn POST (solid) 71.4 ms 64.8 ms +10.26%
Memory mem server serialization-payload (react) 3.5 MB 3.2 MB +8.92%
Simulation ssr server-fn send-context (solid) 71.3 ms 66 ms +8.05%
Simulation ssr server-fn GET (solid) 75.2 ms 70.6 ms +6.46%
Simulation ssr server-fn redirect (solid) 55.5 ms 52.5 ms +5.85%
Memory mem client navigation-churn (solid) 622 KB 590.1 KB +5.41%
Memory mem client preload-churn (vue) 779.6 KB 739.6 KB +5.41%
Memory mem server server-fn-churn (vue) 273.8 KB 263.3 KB +3.98%
Memory mem server server-fn-churn (react) 283.6 KB 273.2 KB +3.81%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix-lane-loader-review-regressions (33588d1) with fix-router-core-lane-match-loader (f84d087)1

Open in CodSpeed

Footnotes

  1. No successful run was found on fix-router-core-lane-match-loader (90a7f39) during the generation of this report, so 46d12b8 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

…budget

The cache-replacement test warmed Vite's lazy transform of
BaseTanStackRouterDevtoolsPanel inside the test body, so on slow CI
runners the transform alone could blow the 5s test timeout (observed at
5.89s). Move the warm-up to a beforeAll with its own generous timeout
and give the test itself explicit headroom. Pre-existing flake on the
lane branch tip, surfaced by this PR's CI being the first to run on it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The lane pipeline already carried phase brands at lane granularity
(Lane<'matched'|'contextualized'|'reduced'|'projected'>); this finishes
the pattern at the two granularities it was missing, at zero runtime
cost (all emitted dist JS verified byte-identical):

- settleInto becomes the sole granter of a SettledMatch brand via an
  assertion signature, and cacheLoaderMatch requires it — the
  loader -> settle -> cache ordering is now compiler-enforced. The one
  legitimate phase jump (hydration cache-seeding of already-settled
  dehydrated data) is a single named, commented boundary cast.
- commitMatches/commitRefreshMatches only accept a projected lane's
  matches (LaneMatches<'projected'>), so committing an earlier-phase
  lane no longer compiles.
- LoadTransaction's dev-only refresh triple collapses into one optional
  slot [presentation, handoff?], making a half-armed refresh state
  unrepresentable and shrinking the clear/read sites.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Sheraff
Sheraff merged commit baa18cd into fix-router-core-lane-match-loader Jul 23, 2026
25 of 26 checks passed
@Sheraff
Sheraff deleted the fix-lane-loader-review-regressions branch July 23, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant