Skip to content

perf(ssr): reduce request cancellation overhead#7862

Merged
Sheraff merged 1 commit into
codex/match-loading-finalfrom
perf/ssr-request-cancellation
Jul 20, 2026
Merged

perf(ssr): reduce request cancellation overhead#7862
Sheraff merged 1 commit into
codex/match-loading-finalfrom
perf/ssr-request-cancellation

Conversation

@Sheraff

@Sheraff Sheraff commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • share one abort listener across server waits for the same request signal while preserving late-result cleanup
  • skip redundant cancellation wrappers when middleware directly returns next(), with guarded abort precedence and stream disposal
  • cover concurrent waiters, signal isolation, registration races, nested middleware unwinding, and fulfilled/rejected abort races

Performance

Controlled Solid SSR benchmarks:

Scenario Base branch This PR Change
server route 3.8324 ms 3.4374 ms 10.3% faster
middleware server route 4.5093 ms 3.5933 ms 20.3% faster

The final results are within 0.3% of the pre-regression route baseline and 0.2% of the pre-regression middleware baseline, both inside benchmark noise.

A same-worktree before/after run of all 17 client bundle scenarios reported exact zero deltas for gzip, initial gzip, raw, and Brotli sizes.

Validation

  • @tanstack/router-core:test:unit: 99 files, 1,454 tests passed or expected-fail
  • @tanstack/start-server-core:test:unit: 7 files, 114 tests passed
  • Router Core and Start Server Core type matrices passed on TypeScript 5.5 through 6.0
  • package ESLint and build targets passed
  • Solid aborted-request memory workload passed
  • git diff --check passed

@coderabbitai

coderabbitai Bot commented Jul 20, 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: b6619965-6fdb-4126-b498-9d650e8ef807

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 perf/ssr-request-cancellation

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

@nx-cloud

nx-cloud Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit ee1c29e

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

☁️ Nx Cloud last updated this comment at 2026-07-20 16:27:37 UTC

@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: 5059c4bf5f27
  • Measured at: 2026-07-20T16:14:19.821Z
  • Baseline source: history:edf55759d8e9
  • Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Initial gzip Raw Brotli Trend
react-router.minimal 87.33 KiB -22 B (-0.02%) 87.19 KiB 269.82 KiB 76.06 KiB ███████████▁
react-router.full 91.01 KiB -57 B (-0.06%) 90.87 KiB 281.55 KiB 79.33 KiB ███████████▁
solid-router.minimal 35.08 KiB -452 B (-1.24%) 34.96 KiB 100.64 KiB 31.65 KiB ███████████▁
solid-router.full 40.02 KiB -580 B (-1.40%) 39.89 KiB 115.51 KiB 36.02 KiB ███████████▁
vue-router.minimal 52.36 KiB -658 B (-1.21%) 52.23 KiB 144.04 KiB 47.17 KiB ███████████▁
vue-router.full 58.29 KiB -662 B (-1.10%) 58.16 KiB 162.57 KiB 52.34 KiB ███████████▁
react-start.minimal 102.32 KiB +338 B (+0.32%) 102.18 KiB 318.40 KiB 88.61 KiB ▁▁▁▁▁▁▁▁▁▁▁█
react-start.deferred-hydration 103.05 KiB +339 B (+0.32%) 102.20 KiB 319.78 KiB 89.25 KiB ▁▁▁▁▁▁▁▁▁▁▁█
react-start.full 105.63 KiB +276 B (+0.26%) 105.50 KiB 328.33 KiB 91.50 KiB ▁▁▁▁▁▁▁▁▁▁▁█
react-start.rsbuild.minimal 99.91 KiB +232 B (+0.23%) 99.74 KiB 312.89 KiB 86.15 KiB ▁▁▁▁▁▁▁▁▁▁▁█
react-start.rsbuild.minimal-iife 100.30 KiB +227 B (+0.22%) 100.14 KiB 313.83 KiB 86.43 KiB ▁▁▁▁▁▁▁▁▁▁▁█
react-start.rsbuild.full 103.23 KiB +343 B (+0.33%) 103.06 KiB 322.97 KiB 88.90 KiB ▁▁▁▁▁▁▁▁▁▁▁█
solid-start.minimal 49.88 KiB +274 B (+0.54%) 49.75 KiB 148.13 KiB 44.20 KiB ▁▁▁▁▁▁▁▁▁▁▁█
solid-start.deferred-hydration 53.14 KiB +279 B (+0.52%) 49.81 KiB 156.17 KiB 47.21 KiB ▁▁▁▁▁▁▁▁▁▁▁█
solid-start.full 55.12 KiB -311 B (-0.55%) 54.99 KiB 163.75 KiB 48.66 KiB ███████████▁
vue-start.minimal 70.68 KiB -358 B (-0.49%) 70.55 KiB 201.40 KiB 62.73 KiB ███████████▁
vue-start.full 74.67 KiB -366 B (-0.48%) 74.54 KiB 213.98 KiB 66.22 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 20, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-rsc

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: ee1c29e

@codspeed-hq

codspeed-hq Bot commented Jul 20, 2026

Copy link
Copy Markdown

Merging this PR will regress 3 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

⚡ 60 improved benchmarks
❌ 3 regressed benchmarks
✅ 117 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 redirect (solid) 295.2 KB 479 KB -38.38%
Simulation ssr server-fn during document ssr (react) 66.3 ms 71 ms -6.62%
Memory mem server error-paths not-found (vue) 331.1 KB 341.8 KB -3.12%
Memory mem server peak-large-page (react) 2,351.6 KB 942.5 KB ×2.5
Memory mem server error-paths not-found (solid) 710.4 KB 402.9 KB +76.31%
Simulation ssr server-route middleware (vue) 73.8 ms 56.2 ms +31.4%
Simulation ssr server-route middleware (react) 73.9 ms 56.4 ms +31.01%
Simulation ssr server-route middleware (solid) 73.2 ms 55.9 ms +30.93%
Simulation ssr global-mw server-route (solid) 80.5 ms 62 ms +29.93%
Simulation ssr redirect (solid) 47.5 ms 36.8 ms +29.01%
Simulation ssr global-mw server-route (vue) 86.9 ms 68.6 ms +26.71%
Memory mem server peak-large-page (solid) 1,017 KB 825.1 KB +23.26%
Simulation ssr server-route (react) 68.3 ms 56.6 ms +20.67%
Simulation ssr server-route (vue) 67.9 ms 56.2 ms +20.64%
Simulation ssr server-route (solid) 64.8 ms 54.2 ms +19.47%
Memory mem server error-paths redirect (vue) 507.9 KB 434.3 KB +16.94%
Simulation ssr global-mw server-fn (solid) 67.1 ms 57.9 ms +15.94%
Simulation ssr global-mw server-route (react) 67.6 ms 58.8 ms +14.92%
Simulation ssr redirect (react) 43.4 ms 37.9 ms +14.42%
Simulation ssr server-fn redirect (vue) 73 ms 64.2 ms +13.71%
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

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


Comparing perf/ssr-request-cancellation (ee1c29e) with codex/match-loading-final (8ad0dc5)

Open in CodSpeed

@Sheraff
Sheraff merged commit dd7fb57 into codex/match-loading-final Jul 20, 2026
25 of 26 checks passed
@Sheraff
Sheraff deleted the perf/ssr-request-cancellation branch July 20, 2026 16:35
Sheraff added a commit that referenced this pull request Jul 20, 2026
* fix(router-core): complete lane match loader rewrite

* fix(router-core): harden match loading lifecycle

* fix(router-core): preserve hydrated context handoff

* bench(memory): accept expected abort errors

* perf(ssr): reduce request cancellation overhead (#7862)
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