Skip to content

Always execute beforeLoad for client lanes - #7922

Merged
Sheraff merged 4 commits into
fix-router-core-lane-match-loaderfrom
codex/always-run-beforeload
Jul 30, 2026
Merged

Always execute beforeLoad for client lanes#7922
Sheraff merged 4 commits into
fix-router-core-lane-match-loaderfrom
codex/always-run-beforeload

Conversation

@Sheraff

@Sheraff Sheraff commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

What changed

  • run beforeLoad independently for every client navigation and preload lane, including identical and same-location requests
  • keep loader reuse separate, allowing completed and in-flight loader generations to remain shareable by match ID
  • remove whole-preload-lane adoption and same-location transaction deduplication
  • narrow loader-flight reservation to navigation handoff and active beforeLoad planning
  • make invalidation and filtered clearCache preserve correct loader ownership
  • remove the urgent mode from StartTransitionFn
  • update the orchestration documentation and add public-API regressions for supersession, invalidation, cache clearing, and signal lifetime

Why

beforeLoad carries lane-specific guard and context semantics, so adopting it from cache or another in-flight lane can expose stale context and control flow. Loader data is the intended reusable boundary. Separating these rules simplifies the match-loading architecture while retaining loader deduplication.

The previous broad reservation and lane-adoption mechanisms also made it possible to leak zero-owner loader flights, replay stale work after invalidation, or make retained shared work undiscoverable during filtered cache clearing.

Impact

Every client lane now evaluates its own beforeLoad. Loader work can still be reused from cache or an in-flight generation, even when lane arguments such as preload or context differ. The resulting orchestration has fewer semantic authorities and removes per-preload full-flight-registry sweeps.

Validation

  • router-core unit tests: 1,506 passed, 3 expected failures
  • react-router unit tests: 986 passed, 1 skipped
  • router-core and react-router TypeScript version matrices
  • router-core and react-router ESLint targets (no errors; existing warnings only)
  • full bundle-size suite: gzip decreased in all 17 scenarios; react-router.minimal decreased by 166 bytes

@coderabbitai

coderabbitai Bot commented Jul 30, 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 Plus

Run ID: 13912467-ff37-4872-b71b-b9e7d1885eba

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

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.

❤️ Share

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

@Sheraff
Sheraff marked this pull request as ready for review July 30, 2026 10:15
@nx-cloud

nx-cloud Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 79c00bc

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

☁️ Nx Cloud last updated this comment at 2026-07-30 11:01:24 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 30, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: 535fd16a1219
  • Measured at: 2026-07-30T11:36:36.815Z
  • Baseline source: history:a3ee355b5934
  • 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.21 KiB -145 B (-0.16%) 87.07 KiB 269.46 KiB 75.94 KiB ███████████▁
react-router.full 91.00 KiB -69 B (-0.07%) 90.86 KiB 281.47 KiB 79.30 KiB ███████████▁
solid-router.minimal 34.91 KiB -629 B (-1.73%) 34.79 KiB 100.24 KiB 31.48 KiB ███████████▁
solid-router.full 40.01 KiB -582 B (-1.40%) 39.89 KiB 115.47 KiB 36.00 KiB ███████████▁
vue-router.minimal 52.22 KiB -802 B (-1.48%) 52.08 KiB 143.40 KiB 47.04 KiB ███████████▁
vue-router.full 58.19 KiB -769 B (-1.27%) 58.05 KiB 162.17 KiB 52.25 KiB ███████████▁
react-start.minimal 102.20 KiB +215 B (+0.21%) 102.06 KiB 318.61 KiB 88.84 KiB ▁▁▁▁▁▁▁▁▁▁▁█
react-start.deferred-hydration 102.93 KiB +214 B (+0.20%) 102.08 KiB 319.99 KiB 89.33 KiB ▁▁▁▁▁▁▁▁▁▁▁█
react-start.full 105.61 KiB +251 B (+0.23%) 105.47 KiB 328.61 KiB 91.55 KiB ▁▁▁▁▁▁▁▁▁▁▁█
react-start.rsbuild.minimal 99.91 KiB +223 B (+0.22%) 99.74 KiB 312.99 KiB 86.22 KiB ▁▁▁▁▁▁▁▁▁▁▁█
react-start.rsbuild.minimal-iife 100.31 KiB +219 B (+0.21%) 100.14 KiB 313.93 KiB 86.56 KiB ▁▁▁▁▁▁▁▁▁▁▁█
react-start.rsbuild.full 103.24 KiB +343 B (+0.33%) 103.07 KiB 323.14 KiB 88.92 KiB ▁▁▁▁▁▁▁▁▁▁▁█
solid-start.minimal 49.84 KiB +239 B (+0.47%) 49.71 KiB 148.28 KiB 44.31 KiB ▁▁▁▁▁▁▁▁▁▁▁█
solid-start.deferred-hydration 53.11 KiB +243 B (+0.45%) 49.77 KiB 156.32 KiB 47.28 KiB ▁▁▁▁▁▁▁▁▁▁▁█
solid-start.full 55.11 KiB -318 B (-0.56%) 54.98 KiB 164.07 KiB 48.82 KiB ███████████▁
vue-start.minimal 70.59 KiB -447 B (-0.61%) 70.46 KiB 201.32 KiB 62.65 KiB ███████████▁
vue-start.full 74.57 KiB -476 B (-0.62%) 74.43 KiB 213.93 KiB 66.16 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 30, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-rsc

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: db9445d

@codspeed-hq

codspeed-hq Bot commented Jul 30, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 12.74%

⚠️ 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

⚡ 5 improved benchmarks
❌ 8 regressed benchmarks
✅ 167 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) 261.3 KB 596.3 KB -56.18%
Memory mem server error-paths redirect (vue) 306 KB 630.6 KB -51.47%
Memory mem client unique-location-churn (react) 665.1 KB 872.7 KB -23.79%
Memory mem server error-paths not-found (solid) 751.3 KB 818.3 KB -8.18%
Memory mem server streaming-peak chunked (vue) 11.1 MB 11.6 MB -4.85%
Simulation ssr control-flow route headers (react) 60.3 ms 62.7 ms -3.8%
Simulation ssr selective (solid) 70.3 ms 72.9 ms -3.62%
Simulation client-rewrites navigation loop (solid) 81.8 ms 84.5 ms -3.19%
Memory mem client navigation-churn (solid) 544.9 KB 498.5 KB +9.31%
Memory mem server error-paths redirect (react) 201.8 KB 185.2 KB +8.97%
Simulation ssr server-fn multipart (solid) 64.2 ms 61.2 ms +4.86%
Simulation client-preload interaction loop (react) 55.4 ms 53.4 ms +3.63%
Simulation ssr server-fn raw-stream (solid) 111.7 ms 108.1 ms +3.36%

Tip

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


Comparing codex/always-run-beforeload (d49f47f) with fix-router-core-lane-match-loader (2d639e1)

Open in CodSpeed

@github-actions github-actions Bot added the documentation Everything documentation related label Jul 30, 2026
@Sheraff
Sheraff merged commit 1d20a9d into fix-router-core-lane-match-loader Jul 30, 2026
23 checks passed
@Sheraff
Sheraff deleted the codex/always-run-beforeload branch July 30, 2026 11:34
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