Skip to content

perf: skip unused Start request setup - #8451

Open
schiller-manuel wants to merge 2 commits into
codex/skip-unused-start-routingfrom
codex/trim-unused-start-request-work
Open

schiller-manuel wants to merge 2 commits into
codex/skip-unused-start-routingfrom
codex/trim-unused-start-request-work

Conversation

@schiller-manuel

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

Copy link
Copy Markdown
Collaborator

🎯 Changes

Stacked on #8444.

Skip request setup when its corresponding Start feature is unused:

  • Render directly when matched routes have no middleware or handler to execute, preserving HEAD fallback behavior.
  • Return cached manifest promises directly when asset options are static.
  • Skip empty middleware flattening and deduplication sets, and avoid awaiting absent Start configuration.
  • Reuse the parsed request origin and serialization adapters.
  • Use the router's decoded pathname for server route handlers and route middleware.

Validation: affected unit, type, and lint checks across 16 projects; server-route and global server-function middleware Chromium suites (13 tests). All 18 client bundle scenarios have unchanged raw, gzip, initial-gzip, and Brotli sizes.

✅ 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

  • Bug Fixes
    • Improved handling of requests without configured Start instances or middleware.
    • Corrected server route handling for encoded and decoded pathnames.
    • Ensured request origins are derived consistently from the request URL.
    • Preserved middleware execution context and serialization adapter ordering across requests.
    • Improved cached manifest reuse when asset transformation is not configured.
  • Tests
    • Expanded coverage for server rendering, middleware behavior, request origins, path parameters, serialization adapters, and manifest caching.

@coderabbitai

coderabbitai Bot commented Sep 16, 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: 6d9df1f4-7029-4788-8c4c-4afc7dd0ff19

📥 Commits

Reviewing files that changed from the base of the PR and between 92dfe48 and 9dffae9.

📒 Files selected for processing (7)
  • .changeset/honest-walls-attack.md
  • packages/start-client-core/src/createServerFn.ts
  • packages/start-server-core/src/createStartHandler.ts
  • packages/start-server-core/src/finalManifest.ts
  • packages/start-server-core/tests/createStartHandler.test.ts
  • packages/start-server-core/tests/finalManifest.test.ts
  • packages/start-storage-context/src/async-local-storage.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • .changeset/honest-walls-attack.md
  • packages/start-client-core/src/createServerFn.ts

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


📝 Walkthrough

Walkthrough

The changes update server request routing, middleware execution, serialization adapter handling, request origin resolution, decoded pathname handling, and final manifest caching. Tests cover these behaviors, and a changeset records patch releases.

Changes

Server runtime fixes

Layer / File(s) Summary
Request routing and middleware execution
packages/start-storage-context/src/async-local-storage.ts, packages/start-client-core/src/createServerFn.ts, packages/start-server-core/src/createStartHandler.ts, packages/start-server-core/tests/createStartHandler.test.ts, .changeset/honest-walls-attack.md
Start configuration and middleware state can be absent. Empty middleware chains are skipped. Router origins use the request URL. Serialization adapters remain ordered and request-isolated. Server handlers use decoded route pathnames while preserving encoded pathname data.
Final manifest cache resolution
packages/start-server-core/src/finalManifest.ts, packages/start-server-core/tests/finalManifest.test.ts
Cached manifests are returned directly when asset transformation is not configured and the requested inline-CSS mode matches a cached entry. Tests cover cache reuse, overrides, uncached loading, and request-dependent CSS settings.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Suggested reviewers: sheraff

Sequence Diagram(s)

sequenceDiagram
  participant Request
  participant createStartHandler
  participant Router
  participant executeRouter
  Request->>createStartHandler: request URL and request context
  createStartHandler->>Router: configure origin and serialization adapters
  Router->>createStartHandler: matched routes and latest pathname
  createStartHandler->>executeRouter: execute route without empty middleware chain
  executeRouter-->>Request: server route response
Loading

Merge Risk: ⚪ Minimal · up to 9dffa

The optimized request and manifest paths preserve their relevant middleware and cache contracts, with no unresolved merge-blocking issue identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 6 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the primary change: skipping unused Start request setup. It is concise and relevant to the performance optimizations in the pull request.
Description check ✅ Passed The description follows the required template. It explains the changes and motivation, confirms testing and contributor-guide compliance, and records the published-code impact with a changeset.
Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 6 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ 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/trim-unused-start-request-work

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 16, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 9dffae9

Command Status Duration Result
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 27s View ↗

☁️ Nx Cloud last updated this comment at 2026-09-16 21:24:40 UTC

@schiller-manuel
schiller-manuel added this pull request to stack #8445 September 16, 2026 18:28
@github-actions

github-actions Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

4 package(s) bumped directly, 19 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/router-core 1.171.31 → 1.171.32 Changeset
@tanstack/start-plugin-core 1.171.45 → 1.171.46 Changeset
@tanstack/start-server-core 1.169.36 → 1.169.37 Changeset
@tanstack/start-storage-context 1.167.33 → 1.167.34 Changeset
@tanstack/react-router 1.170.37 → 1.170.38 Dependent
@tanstack/react-start 1.168.55 → 1.168.56 Dependent
@tanstack/react-start-client 1.168.35 → 1.168.36 Dependent
@tanstack/react-start-rsc 0.1.54 → 0.1.55 Dependent
@tanstack/react-start-server 1.167.42 → 1.167.43 Dependent
@tanstack/router-cli 1.167.37 → 1.167.38 Dependent
@tanstack/router-generator 1.167.37 → 1.167.38 Dependent
@tanstack/router-plugin 1.168.39 → 1.168.40 Dependent
@tanstack/router-vite-plugin 1.167.39 → 1.167.40 Dependent
@tanstack/solid-router 1.170.35 → 1.170.36 Dependent
@tanstack/solid-start 1.168.53 → 1.168.54 Dependent
@tanstack/solid-start-client 1.168.34 → 1.168.35 Dependent
@tanstack/solid-start-server 1.167.41 → 1.167.42 Dependent
@tanstack/start-client-core 1.170.31 → 1.170.32 Dependent
@tanstack/start-static-server-functions 1.167.36 → 1.167.37 Dependent
@tanstack/vue-router 1.170.34 → 1.170.35 Dependent
@tanstack/vue-start 1.168.52 → 1.168.53 Dependent
@tanstack/vue-start-client 1.167.37 → 1.167.38 Dependent
@tanstack/vue-start-server 1.167.41 → 1.167.42 Dependent

@pkg-pr-new

pkg-pr-new Bot commented Sep 16, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-rsc

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: 9dffae9

@github-actions

github-actions Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

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

@codspeed

codspeed Bot commented Sep 16, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 0.09%

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

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 187 untouched benchmarks
⏩ 3 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem client unique-location-churn (vue) 2 MB 2.1 MB -4.27%
Simulation ssr rewrite localized (react) 182.4 ms 174.9 ms +4.27%

Tip

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


Comparing codex/trim-unused-start-request-work (9dffae9) with codex/skip-unused-start-routing (6604453)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@schiller-manuel
schiller-manuel force-pushed the codex/trim-unused-start-request-work branch from d3c2816 to 001baa4 Compare September 16, 2026 18:45

@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

@schiller-manuel
schiller-manuel force-pushed the codex/trim-unused-start-request-work branch from 92dfe48 to 9dffae9 Compare September 16, 2026 21:11
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