Skip to content

perf: skip unused Start server routing work - #8444

Open
schiller-manuel wants to merge 2 commits into
codex/reuse-ssr-request-locationfrom
codex/skip-unused-start-routing
Open

schiller-manuel wants to merge 2 commits into
codex/reuse-ssr-request-locationfrom
codex/skip-unused-start-routing

Conversation

@schiller-manuel

@schiller-manuel schiller-manuel commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

🎯 Changes

Stacked on #8441.

Apps without a server option on any route can skip server-route handling. Detect this during the existing Start build passes and emit a boolean in the server manifest. A single shared Start plugin handles the route metadata and compiler hooks.

Also skip the request middleware chain when none are configured, cache entry imports in one function, and reuse the local router instance when early hints need route matching.

Validation: affected unit, type, and lint checks passed; 46 Chromium cases passed across server routes, early hints, dev SSR styles, and custom Rsbuild servers. The standard Rsbuild production build also passed.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with the relevant test commands, or tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Performance Improvements

    • Apps without server routes now skip unnecessary server-route processing.
    • Requests skip middleware processing when no request middleware is configured.
    • Route handling is deferred when possible for faster request startup.
  • Bug Fixes

    • Early hints and matched-route information are preserved when server-route processing is skipped.
    • Server-route detection now works more reliably across development and production builds.
  • Tests

    • Added coverage for server-route detection, middleware behavior, manifest generation, and early hints.

@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 20cf2f0c-3317-4294-9464-6e9d9711f158

📥 Commits

Reviewing files that changed from the base of the PR and between b7600ee and 9c59167.

📒 Files selected for processing (19)
  • .changeset/skip-unused-start-routing.md
  • packages/start-plugin-core/src/global.d.ts
  • packages/start-plugin-core/src/rsbuild/start-router-plugin.ts
  • packages/start-plugin-core/src/rsbuild/virtual-modules.ts
  • packages/start-plugin-core/src/start-manifest-plugin/manifestBuilder.ts
  • packages/start-plugin-core/src/start-router-plugin/generator-plugins/routes-manifest-plugin.ts
  • packages/start-plugin-core/src/start-router-plugin/pruneServerOnlySubtrees.ts
  • packages/start-plugin-core/src/vite/dev-server-plugin/plugin.ts
  • packages/start-plugin-core/src/vite/start-manifest-plugin/plugin.ts
  • packages/start-plugin-core/src/vite/start-router-plugin/plugin.ts
  • packages/start-plugin-core/tests/routes-manifest-plugin.test.ts
  • packages/start-plugin-core/tests/rsbuild/virtual-modules.test.ts
  • packages/start-plugin-core/tests/start-manifest-plugin.test.ts
  • packages/start-plugin-core/tests/start-manifest-plugin/manifestBuilder.test.ts
  • packages/start-server-core/src/createStartHandler.ts
  • packages/start-server-core/src/tanstack-start.d.ts
  • packages/start-server-core/tests/createStartHandler.test.ts
  • packages/start-server-core/tests/fixtures/start-manifest.ts
  • packages/start-server-core/tsconfig.json

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

Changes

Server route detection and manifest propagation

Layer / File(s) Summary
Route metadata and detection
packages/start-plugin-core/src/global.d.ts, packages/start-plugin-core/src/start-manifest-plugin/manifestBuilder.ts, packages/start-plugin-core/src/start-router-plugin/*, packages/start-plugin-core/tests/routes-manifest-plugin.test.ts
Route manifests now include optional hasServerRoutes metadata. Route option analysis detects explicit, computed, getter, and spread server options.
Manifest generation and plugin wiring
packages/start-plugin-core/src/rsbuild/*, packages/start-plugin-core/src/vite/*, packages/start-plugin-core/tests/rsbuild/*, packages/start-plugin-core/tests/start-manifest-plugin*
Vite and Rsbuild manifest modules export hasServerRoutes. Build plugins share the route manifest plugin and pass it to client code splitting when required.
Server request path selection
packages/start-server-core/src/createStartHandler.ts, packages/start-server-core/src/tanstack-start.d.ts, packages/start-server-core/tests/createStartHandler.test.ts, packages/start-server-core/tests/fixtures/*, packages/start-server-core/tsconfig.json
The handler reads manifest metadata, skips server-route handling when no server routes exist, preserves early-hint matching, and skips the request middleware chain when none are configured.
Release metadata
.changeset/skip-unused-start-routing.md
Patch releases are declared for @tanstack/start-server-core and @tanstack/start-plugin-core.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant RoutePlugin
  participant ManifestModule
  participant createStartHandler
  participant Router
  RoutePlugin->>ManifestModule: generate routes and hasServerRoutes
  ManifestModule->>createStartHandler: expose manifest metadata
  createStartHandler->>Router: executeRouter or handleServerRoutes
  Router-->>createStartHandler: return request response
Loading

Merge Risk: ⚪ Minimal · up to a1fbc

The routing optimization retains conservative fallbacks when metadata is unavailable and preserves server-function CSRF protection. No merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.24% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 29 functions across 17 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary performance change: skipping unused Start server-routing work.
Description check ✅ Passed The description explains the changes and motivation, completes all required checklist items, documents validation, and confirms that a changeset was added.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 17.24% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 29 functions across 17 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/skip-unused-start-routing

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.

@nx-cloud

nx-cloud Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit a1fbcb0

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

☁️ Nx Cloud last updated this comment at 2026-09-16 00:15:49 UTC

@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

This pull request does not affect bundle size in any measured scenario.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

6 package(s) bumped directly, 17 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/react-router 1.170.36 → 1.170.37 Changeset
@tanstack/router-core 1.171.30 → 1.171.31 Changeset
@tanstack/solid-router 1.170.34 → 1.170.35 Changeset
@tanstack/start-plugin-core 1.171.44 → 1.171.45 Changeset
@tanstack/start-server-core 1.169.35 → 1.169.36 Changeset
@tanstack/vue-router 1.170.33 → 1.170.34 Changeset
@tanstack/react-start 1.168.54 → 1.168.55 Dependent
@tanstack/react-start-client 1.168.34 → 1.168.35 Dependent
@tanstack/react-start-rsc 0.1.53 → 0.1.54 Dependent
@tanstack/react-start-server 1.167.41 → 1.167.42 Dependent
@tanstack/router-cli 1.167.36 → 1.167.37 Dependent
@tanstack/router-generator 1.167.36 → 1.167.37 Dependent
@tanstack/router-plugin 1.168.38 → 1.168.39 Dependent
@tanstack/router-vite-plugin 1.167.38 → 1.167.39 Dependent
@tanstack/solid-start 1.168.52 → 1.168.53 Dependent
@tanstack/solid-start-client 1.168.33 → 1.168.34 Dependent
@tanstack/solid-start-server 1.167.40 → 1.167.41 Dependent
@tanstack/start-client-core 1.170.30 → 1.170.31 Dependent
@tanstack/start-static-server-functions 1.167.35 → 1.167.36 Dependent
@tanstack/start-storage-context 1.167.32 → 1.167.33 Dependent
@tanstack/vue-start 1.168.51 → 1.168.52 Dependent
@tanstack/vue-start-client 1.167.36 → 1.167.37 Dependent
@tanstack/vue-start-server 1.167.40 → 1.167.41 Dependent

@pkg-pr-new

pkg-pr-new Bot commented Sep 15, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-rsc

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: a1fbcb0

@codspeed

codspeed Bot commented Sep 15, 2026

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

⚡ 12 improved benchmarks
❌ 1 regressed benchmark
✅ 167 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem server request-churn (react) 985.2 KB 1,114.3 KB -11.58%
Simulation ssr redirect (solid) 116.3 ms 98.4 ms +18.18%
Simulation ssr redirect (vue) 119.3 ms 101.3 ms +17.75%
Simulation ssr redirect (react) 123.4 ms 105.3 ms +17.18%
Simulation ssr server-route middleware (solid) 152.6 ms 143.2 ms +6.58%
Simulation ssr server-route middleware (react) 155.9 ms 146.5 ms +6.42%
Simulation ssr before-load chain (react) 174.4 ms 164 ms +6.31%
Simulation ssr server-route (solid) 138.3 ms 130.5 ms +5.94%
Simulation ssr rewrite passthrough (react) 184.4 ms 174.1 ms +5.94%
Simulation ssr server-route (react) 142.9 ms 134.9 ms +5.92%
Simulation ssr control-flow unmatched 404 (vue) 497.9 ms 471.1 ms +5.7%
Simulation ssr server-route (vue) 140.6 ms 134.1 ms +4.87%
Simulation ssr server-route middleware (vue) 154.3 ms 149.4 ms +3.26%

Tip

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


Comparing codex/skip-unused-start-routing (a1fbcb0) with codex/reuse-ssr-request-location (b7600ee)

Open in CodSpeed

@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.

Nx Cloud has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

Nx Cloud View detailed reasoning in Nx Cloud ↗


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

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