Skip to content

perf(start-server-core): skip update for server context#7599

Merged
Sheraff merged 2 commits into
mainfrom
perf/ssr-additional-context-update
Jun 11, 2026
Merged

perf(start-server-core): skip update for server context#7599
Sheraff merged 2 commits into
mainfrom
perf/ssr-additional-context-update

Conversation

@Sheraff

@Sheraff Sheraff commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Set request-scoped additionalContext directly before router.load()
  • Avoid an unnecessary router.update() and redundant location parse during SSR

Tests

  • CI=1 NX_DAEMON=false pnpm nx run @tanstack/start-server-core:test:types --outputStyle=stream --skipRemoteCache
  • CI=1 NX_DAEMON=false pnpm nx run @tanstack/start-server-core:test:unit --outputStyle=stream --skipRemoteCache

Summary by CodeRabbit

  • Refactor
    • Improved server-side startup path to reduce SSR overhead, resulting in faster initial responses and lower latency during server rendering. Delivered as a minor patch with no public API changes.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e6708028-5d83-4cf2-866d-f9a15f3aac3f

📥 Commits

Reviewing files that changed from the base of the PR and between 7eb946a and a3026ac.

📒 Files selected for processing (1)
  • .changeset/large-insects-own.md
✅ Files skipped from review due to trivial changes (1)
  • .changeset/large-insects-own.md

📝 Walkthrough

Walkthrough

The PR changes createStartHandler to inject per-request serverContext by directly assigning routerInstance.options.additionalContext (replacing a prior router.update call) and adds a changeset documenting the patch release.

Changes

Router Context Injection Optimization

Layer / File(s) Summary
Direct options assignment
packages/start-server-core/src/createStartHandler.ts, .changeset/large-insects-own.md
serverContext is injected by directly assigning routerInstance.options.additionalContext instead of calling routerInstance.update() before router load; a changeset notes a patch bump.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • schiller-manuel

Poem

🐰 I hop to set context, quick and spry,
No update roundabout — just assign and fly.
A tidy start, the router wakes with cheer,
Tiny patch, swift path, the endpoint's near. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly reflects the main change: skipping an unnecessary router.update() call for performance optimization in start-server-core when setting server context.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/ssr-additional-context-update

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

@nx-cloud

nx-cloud Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 7eb946a

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

☁️ Nx Cloud last updated this comment at 2026-06-11 08:25:03 UTC

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

3 package(s) bumped directly, 10 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/react-router 1.170.15 → 1.170.16 Changeset
@tanstack/solid-router 1.170.15 → 1.170.16 Changeset
@tanstack/start-server-core 1.169.14 → 1.169.15 Changeset
@tanstack/react-start 1.168.25 → 1.168.26 Dependent
@tanstack/react-start-client 1.168.13 → 1.168.14 Dependent
@tanstack/react-start-rsc 0.1.24 → 0.1.25 Dependent
@tanstack/react-start-server 1.167.19 → 1.167.20 Dependent
@tanstack/solid-start 1.168.25 → 1.168.26 Dependent
@tanstack/solid-start-client 1.168.13 → 1.168.14 Dependent
@tanstack/solid-start-server 1.167.19 → 1.167.20 Dependent
@tanstack/start-plugin-core 1.171.17 → 1.171.18 Dependent
@tanstack/vue-start 1.168.24 → 1.168.25 Dependent
@tanstack/vue-start-server 1.167.19 → 1.167.20 Dependent

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: 5d26c5a18ea2
  • Measured at: 2026-06-11T08:09:02.926Z
  • Baseline source: history:56bd271ba088
  • Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Initial gzip Raw Brotli Trend
react-router.minimal 87.29 KiB 0 B (0.00%) 87.15 KiB 273.66 KiB 75.88 KiB ▁▁▁▁▁▁▁▁▁▃█
react-router.full 91.02 KiB 0 B (0.00%) 90.88 KiB 285.56 KiB 79.09 KiB ██████▁▁▁▁▄
solid-router.minimal 35.48 KiB 0 B (0.00%) 35.36 KiB 105.86 KiB 32.03 KiB ▆▆▆▆▆▆▆█▁▁▁
solid-router.full 40.53 KiB 0 B (0.00%) 40.41 KiB 121.08 KiB 36.46 KiB ▆▆▆▆▆▆▆█▁▁▁
vue-router.minimal 52.97 KiB 0 B (0.00%) 52.84 KiB 149.90 KiB 47.62 KiB ███████▁▁▁▁
vue-router.full 58.96 KiB 0 B (0.00%) 58.83 KiB 168.66 KiB 52.87 KiB ▁▁▁▁▁▁▁████
react-start.minimal 101.91 KiB 0 B (0.00%) 101.77 KiB 321.98 KiB 88.21 KiB ▁▁▁▁▁▁▁▂▂▃█
react-start.deferred-hydration 102.65 KiB 0 B (0.00%) 101.80 KiB 323.36 KiB 88.90 KiB ▁▁▁▁▁▁▂▂▂▂█
react-start.full 105.31 KiB 0 B (0.00%) 105.18 KiB 331.91 KiB 91.06 KiB ▃▃████▁▁▁▂▆
react-start.rsbuild.minimal 99.63 KiB 0 B (0.00%) 99.46 KiB 316.43 KiB 85.79 KiB ▃▃▃▃▃▃▁▂▂▃█
react-start.rsbuild.minimal-iife 100.03 KiB 0 B (0.00%) 99.87 KiB 317.37 KiB 86.08 KiB ▃▃▃▃▃▃▁▂▂▃█
react-start.rsbuild.full 102.86 KiB 0 B (0.00%) 102.68 KiB 326.48 KiB 88.53 KiB ▅▅████▁▁▁▁▅
solid-start.minimal 49.60 KiB 0 B (0.00%) 49.47 KiB 151.93 KiB 43.79 KiB ▆▆▆▆▆▆▆█▁▁▁
solid-start.deferred-hydration 52.86 KiB 0 B (0.00%) 49.53 KiB 159.97 KiB 46.81 KiB ▄▄▄▄▄▄▄█▁▁▁
solid-start.full 55.40 KiB 0 B (0.00%) 55.27 KiB 168.97 KiB 48.80 KiB ▁▁▇▇▇▇▇█▆▆▆
vue-start.minimal 71.02 KiB 0 B (0.00%) 70.89 KiB 207.04 KiB 62.93 KiB ▁▁▁▁▁▁▁████
vue-start.full 75.01 KiB 0 B (0.00%) 74.88 KiB 219.68 KiB 66.40 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 Jun 11, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-rsc

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: a3026ac

@codspeed-hq

codspeed-hq Bot commented Jun 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing perf/ssr-additional-context-update (a3026ac) with main (56bd271)

Open in CodSpeed

@Sheraff Sheraff merged commit 96eca43 into main Jun 11, 2026
20 checks passed
@Sheraff Sheraff deleted the perf/ssr-additional-context-update branch June 11, 2026 08:58
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