Skip to content

refactor(router-core): SSR load-matches can skip some updateMatch() calls#6720

Open
Sheraff wants to merge 2 commits intomainfrom
refactor-router-core-ssr-load-matches-skip-match-updates
Open

refactor(router-core): SSR load-matches can skip some updateMatch() calls#6720
Sheraff wants to merge 2 commits intomainfrom
refactor-router-core-ssr-load-matches-skip-match-updates

Conversation

@Sheraff
Copy link
Copy Markdown
Contributor

@Sheraff Sheraff commented Feb 21, 2026

Benchmark

a series of 5 runs of the flamegraph benchmark hitting / (100 links test) yields these results. The improvement is small, but it seems consistent.

Metric Main mean PR mean Delta mean (PR-main) Main median PR median Delta median (PR-main)
Total requests 245,696.0 249,406.4 +3,710.4 (+1.51%) 242,370 245,328 +2,958 (+1.22%)
Requests/sec 8,190.32 8,313.60 +123.28 (+1.51%) 8,079.40 8,176.94 +97.54 (+1.21%)
Latency avg (ms) 0.806 0.748 -0.058 (-7.20%) 0.85 0.80 -0.05 (-5.88%)
Latency p99 (ms) 2.60 2.60 0.00 (0.00%) 3.00 3.00 0.00 (0.00%)
Throughput (MB/s) 16.73 16.98 +0.25 (+1.51%) 16.50 16.70 +0.20 (+1.21%)

Raw results:

main run 1 => total=240537 rps=8018.4 lat_avg_ms=0.89 lat_p99_ms=3 throughput_mb_s=16.38
=== main run 2/5 ===
main run 2 => total=252176 rps=8405.47 lat_avg_ms=0.71 lat_p99_ms=2 throughput_mb_s=17.17
=== main run 3/5 ===
main run 3 => total=242370 rps=8079.4 lat_avg_ms=0.85 lat_p99_ms=3 throughput_mb_s=16.50
=== main run 4/5 ===
main run 4 => total=241498 rps=8050.74 lat_avg_ms=0.86 lat_p99_ms=3 throughput_mb_s=16.45
=== main run 5/5 ===
main run 5 => total=251899 rps=8397.6 lat_avg_ms=0.72 lat_p99_ms=2 throughput_mb_s=17.15

pr-6720 run 1 => total=257058 rps=8568.8 lat_avg_ms=0.65 lat_p99_ms=2 throughput_mb_s=17.50
=== pr-6720 run 2/5 ===
pr-6720 run 2 => total=244657 rps=8155.8 lat_avg_ms=0.81 lat_p99_ms=3 throughput_mb_s=16.66
=== pr-6720 run 3/5 ===
pr-6720 run 3 => total=244632 rps=8154.34 lat_avg_ms=0.81 lat_p99_ms=3 throughput_mb_s=16.66
=== pr-6720 run 4/5 ===
pr-6720 run 4 => total=255357 rps=8512.14 lat_avg_ms=0.67 lat_p99_ms=2 throughput_mb_s=17.39
=== pr-6720 run 5/5 ===
pr-6720 run 5 => total=245328 rps=8176.94 lat_avg_ms=0.8 lat_p99_ms=3 throughput_mb_s=16.70

Summary by CodeRabbit

Bug Fixes

  • Improved overall server-side rendering stability during resource preloading and loading operations by enhancing state management behavior and consistency
  • Fixed inconsistencies in state management that were occurring between server and client implementations during load and preload phases
  • Refined the handling of loading indicators and state transitions within modern server-side rendering environments

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud bot commented Feb 21, 2026

View your CI Pipeline Execution ↗ for commit 8e7412f

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

☁️ Nx Cloud last updated this comment at 2026-03-20 16:15:11 UTC

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 21, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

SSR-aware gating added to the loader pipeline to prevent client-specific state mutations during before-load and loader execution. Conditional checks skip abortController assignment and isFetching updates on the server while preserving client-side behavior.

Changes

Cohort / File(s) Summary
SSR-aware loader state gating
packages/router-core/src/load-matches.ts
Added server-side conditional logic to skip abortController assignment and isFetching state updates during executeBeforeLoad and runLoader execution, preventing client/server mismatches in preloading and loading phases.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • TanStack/router#4971: Modifies executeBeforeLoad and runLoader functions with SSR gating and per-match state handling in the same file.
  • TanStack/router#4992: Changes before-load orchestration and server-side behavior gating in packages/router-core/src/load-matches.ts.
  • TanStack/router#6517: Modifies executeBeforeLoad with SSR-aware gating logic in the same loader pipeline file.

Suggested reviewers

  • schiller-manuel
  • nlynzaad

Poem

🐰 Hopping through the SSR streams,
Gating state from server dreams,
Client-side stays fresh and clean,
No mutations in between!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: SSR-aware optimization that skips certain updateMatch() calls during load-matches processing on the server.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor-router-core-ssr-load-matches-skip-match-updates

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Feb 21, 2026

More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: 8e7412f

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@github-actions
Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: 21e39bde0832
  • Measured at: 2026-03-20T16:05:29.679Z
  • Baseline source: history:91cc62899b75
  • Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Raw Brotli Trend
react-router.minimal 88.56 KiB 0 B (0.00%) 279.34 KiB 76.84 KiB ▁▁▁▁▁▁▁▁███
react-router.full 91.73 KiB 0 B (0.00%) 290.07 KiB 79.48 KiB ▁▁▁▁▁▁▁▁███
solid-router.minimal 36.13 KiB 0 B (0.00%) 108.98 KiB 32.41 KiB ████████▁▁▁
solid-router.full 40.48 KiB +5 B (+0.01%) 122.08 KiB 36.26 KiB ████████▁▁▁▁
vue-router.minimal 54.11 KiB 0 B (0.00%) 155.27 KiB 48.48 KiB ▁▁▁▁▁▁▁▁███
vue-router.full 58.89 KiB 0 B (0.00%) 170.42 KiB 52.63 KiB ▁▁▁▁▁▁▁▁███
react-start.minimal 103.00 KiB 0 B (0.00%) 327.41 KiB 89.02 KiB ▁▁▁▁▁▁▁▁███
react-start.full 106.37 KiB 0 B (0.00%) 337.72 KiB 91.83 KiB ▁▁▁▁▁▁▁▁███
solid-start.minimal 50.32 KiB 0 B (0.00%) 155.47 KiB 44.32 KiB ████████▁▁▁
solid-start.full 55.72 KiB 0 B (0.00%) 171.27 KiB 48.90 KiB ████████▁▁▁

Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 20, 2026

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing refactor-router-core-ssr-load-matches-skip-match-updates (8e7412f) with main (91cc628)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (21e39bd) during the generation of this report, so 91cc628 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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.

2 participants