Skip to content

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

Open
Sheraff wants to merge 1 commit 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 1 commit intomainfrom
refactor-router-core-ssr-load-matches-skip-match-updates

Conversation

@Sheraff
Copy link
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

nx-cloud bot commented Feb 21, 2026

View your CI Pipeline Execution ↗ for commit c08a707

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

☁️ Nx Cloud last updated this comment at 2026-02-21 11:38:11 UTC

@coderabbitai
Copy link
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

pkg-pr-new bot commented Feb 21, 2026

More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: c08a707

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