Skip to content
Source
Sign inSign up
TanStack/router

perf: skip unused Start request setup #8451

Mergedschiller-manuel(GitHub profile, opens in a new tab)merged 1 commit intocodex/reuse-ssr-request-location fromcodex/trim-unused-start-request-workmerged by schiller-manuel(GitHub profile, opens in a new tab)

🎯 Changes

Stacked on #8441.

  • Create the request middleware deduplication set only when request middleware is configured.
  • Pass Start's serialization adapters to the router without copying them when the router adds none.
  • Give server route handlers and route middleware the router's decoded pathname, the one used for route matching. Characters that would change how the path is read, such as %2F, %3F, and %23, stay encoded.

Rebased on main after #7588, which already returns cached manifests directly and reuses the parsed request origin. The earlier skip of the route pipeline is gone: on main that pipeline reconciles responses and owns SSR cleanup, so it has to run.

Validation: start-server-core, start-storage-context, and start-client-core unit, type, and lint checks passed, along with the server-routes (10 tests), server-functions-global-middleware (8 tests), and response-reconciliation (all four modes) e2e. Only server packages change, so client bundles are unaffected.

✅ 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.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      Note

      Currently processing new changes in this PR. This may take a few minutes, please wait...

      ⚙️ Run configuration
      • Configuration used: Repository: TanStack/router/.coderabbit.yaml
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 9d72e5ce-230f-4aca-b840-58172fe3cfcb
      📥 Commits

      Reviewing files that changed from the base of the PR and between 9dffae9090fde178de5f11627c694bf248b1b49f and 272efe1c8abf4b09406b66aad28b0ca219dbebfd.

      📒 Files selected for processing (3)
      • .changeset/honest-walls-attack.md
      • packages/start-server-core/src/createStartHandler.ts
      • packages/start-server-core/tests/createStartHandler.test.ts
       _________________________________________________________________________________________________________________________
      < It is better to have 100 functions operate on one data structure than 10 functions on 10 data structures. - Alan Perlis >
       -------------------------------------------------------------------------------------------------------------------------
        \
         \   (\__/)
             (•ㅅ•)
             /   づ

      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 92dfe48f4621df235e328ef8b8ed4a1d0f5cf3cd and 9dffae9090fde178de5f11627c694bf248b1b49f.

      📒 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

      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 nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring 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 nameStatusExplanation
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Title check✅ PassedThe 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✅ PassedThe 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
      📝 Generate docstrings
      • Create stacked PR
      • Commit on current branch
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR

      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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-server-core

    3. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-client-core

    4. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-storage-context

    5. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 272efe1c8abf4b09406b66aad28b0ca219dbebfd

      CommandStatusDurationResult
      nx run-many --target=build --exclude=examples/*...✅ Succeeded1m 15sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-10-12 23:34:26 UTC

    6. github-actions[bot](GitHub profile, opens in a new tab)commented

      🚀 Changeset Version Preview

      14 package(s) bumped directly, 9 bumped as dependents.

      🟨 Minor bumps

      PackageVersionReason
      @tanstack/react-start1.168.61 → 1.169.0Changeset
      @tanstack/solid-start1.168.58 → 1.169.0Changeset
      @tanstack/vue-start1.168.57 → 1.169.0Changeset

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/react-start-rsc0.1.60 → 0.1.61Changeset
      @tanstack/react-start-server1.167.47 → 1.167.48Changeset
      @tanstack/router-core1.171.35 → 1.171.36Changeset
      @tanstack/router-generator1.167.41 → 1.167.42Changeset
      @tanstack/router-plugin1.168.43 → 1.168.44Changeset
      @tanstack/solid-start-server1.167.45 → 1.167.46Changeset
      @tanstack/start-client-core1.170.35 → 1.170.36Changeset
      @tanstack/start-plugin-core1.171.50 → 1.171.51Changeset
      @tanstack/start-server-core1.169.40 → 1.169.41Changeset
      @tanstack/start-storage-context1.167.37 → 1.167.38Changeset
      @tanstack/vue-start-server1.167.45 → 1.167.46Changeset
      @tanstack/react-router1.170.42 → 1.170.43Dependent
      @tanstack/react-start-client1.168.40 → 1.168.41Dependent
      @tanstack/router-cli1.167.41 → 1.167.42Dependent
      @tanstack/router-vite-plugin1.167.43 → 1.167.44Dependent
      @tanstack/solid-router1.170.39 → 1.170.40Dependent
      @tanstack/solid-start-client1.168.38 → 1.168.39Dependent
      @tanstack/start-static-server-functions1.167.40 → 1.167.41Dependent
      @tanstack/vue-router1.170.38 → 1.170.39Dependent
      @tanstack/vue-start-client1.167.41 → 1.167.42Dependent
    7. pkg-pr-new[bot](GitHub profile, opens in a new tab)commented
      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

    8. github-actions[bot](GitHub profile, opens in a new tab)commented

      Bundle Size Benchmarks

      • Commit: e8d5a7b4eecb
      • Measured at: 2026-10-12T23:34:05.611Z
      • Baseline source: history:80e2eabf482c
      • Dashboard: bundle-size history

      The following scenarios have bundle-size changes compared with the baseline:

      ScenarioCurrent (gzip)Initial (gzip)RawBrotliTrend
      react-start.rsbuild.minimal100.3&nbsp;KiB
      0&nbsp;B
      100.2&nbsp;KiB
      +2&nbsp;B
      313.2&nbsp;KiB
      -4&nbsp;B
      86.7&nbsp;KiB
      +42&nbsp;B
      ▁▁▁▁▁▁█████
      react-start.rsbuild.minimal-iife100.7&nbsp;KiB
      +5&nbsp;B
      100.6&nbsp;KiB
      +7&nbsp;B
      314.2&nbsp;KiB
      -3&nbsp;B
      87.0&nbsp;KiB
      -18&nbsp;B
      ▁▁▁▁▁▁████▄█
      react-start.rsbuild.full103.5&nbsp;KiB
      -3&nbsp;B
      103.3&nbsp;KiB
      -1&nbsp;B
      322.9&nbsp;KiB
      -4&nbsp;B
      89.3&nbsp;KiB
      -49&nbsp;B
      ██████▄▁▁▁▁▁

      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.

    9. codspeed[bot](GitHub profile, opens in a new tab)commented

      Merging this PR will degrade performance by 0.43%

      :information_source: 3 benchmarks have no flame graph

      The flamegraph could not be generated because too much time was spent in runtime internals, making the visualization not useful for performance analysis.

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

      Warning

      Please fix the performance issues or acknowledge them on CodSpeed.

      Performance Changes

      ModeBenchmarkBASEHEADEfficiency
      ❌Memorymem server request-churn (vue)117.8 KB124.2 KB-5.18%
      ⚡Memorymem server error-paths redirect (react)11.3 KB10.8 KB+4.55%

      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 (272efe1) with codex/reuse-ssr-request-location (28ba702) 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. ↩

    10. 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](https://nx.dev/docs/features/ci-features/self-healing-ci?utm_source=pull-request&utm_medium=comment)
    11. 🦋 Changeset detected

      Latest commit: 272efe1c8abf4b09406b66aad28b0ca219dbebfd

      The changes in this PR will be included in the next version bump.

      This PR includes changesets to release 23 packages
      NameType
      @tanstack/router-generatorPatch
      @tanstack/start-server-corePatch
      @tanstack/start-storage-contextPatch
      @tanstack/router-corePatch
      @tanstack/start-client-corePatch
      @tanstack/start-plugin-corePatch
      @tanstack/react-startMinor
      @tanstack/solid-startMinor
      @tanstack/vue-startMinor
      @tanstack/router-pluginPatch
      @tanstack/react-start-serverPatch
      @tanstack/solid-start-serverPatch
      @tanstack/vue-start-serverPatch
      @tanstack/react-start-rscPatch
      @tanstack/router-cliPatch
      @tanstack/react-routerPatch
      @tanstack/react-start-clientPatch
      @tanstack/solid-routerPatch
      @tanstack/solid-start-clientPatch
      @tanstack/vue-routerPatch
      @tanstack/vue-start-clientPatch
      @tanstack/start-static-server-functionsPatch
      @tanstack/router-vite-pluginPatch

      Not sure what this means? Click here to learn what changesets are.

      Click here if you're a maintainer who wants to add another changeset to this PR

Sign in to join this conversation.