Skip to content

fix: pass server context to handler#5601

Merged
schiller-manuel merged 1 commit intoTanStack:mainfrom
salzhrani:fix/pass-server-context-to-handler
Oct 26, 2025
Merged

fix: pass server context to handler#5601
schiller-manuel merged 1 commit intoTanStack:mainfrom
salzhrani:fix/pass-server-context-to-handler

Conversation

@salzhrani
Copy link
Contributor

@salzhrani salzhrani commented Oct 24, 2025

Pass the server context handler

fixes #5371

Summary by CodeRabbit

  • Refactor
    • Updated server context propagation mechanism through route handling middleware to ensure consistent context availability throughout the request processing chain.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2025

Walkthrough

Context parameter propagation through server route handling: handleServerRoutes now accepts and forwards a context: any argument through the middleware chain to executeRouter and executeMiddleware, replacing the previous empty object default.

Changes

Cohort / File(s) Summary
Context propagation in server route handling
packages/start-server-core/src/createStartHandler.ts
Add context: any parameter to handleServerRoutes function; propagate context through middleware chain and executeRouter instead of passing empty object; update call sites to pass context when invoking handleServerRoutes

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • fix: handle synchronous handler/middleware #5270: Both PRs modify packages/start-server-core/src/createStartHandler.ts in the handleServerRoutes and middleware execution areas, with overlapping changes to context and middleware result merging.

Poem

🐰 Through channels of routing, I hop and I bound,
Passing context along without a sound,
Middleware threads now catch every frame,
Context flows freely—no more empty shame! 🎉

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "fix: pass server context to handler" accurately and concisely describes the primary change in this pull request. According to the raw summary, the main modification propagates a new context parameter through server route handling, with handleServerRoutes now accepting and forwarding a context argument through the middleware chain. This directly aligns with the PR's stated objective: "The change passes the server context to the handler." The title is clear, specific, and uses standard convention with the "fix:" prefix, avoiding vague terminology while effectively communicating the core change to reviewers scanning the commit history.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Oct 26, 2025

View your CI Pipeline Execution ↗ for commit 5a8eae6

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

☁️ Nx Cloud last updated this comment at 2025-10-26 10:17:11 UTC

@schiller-manuel schiller-manuel changed the title fix: pass server context to handler fix: pass server context to handler fixes #5371 Oct 26, 2025
@schiller-manuel schiller-manuel changed the title fix: pass server context to handler fixes #5371 fix: pass server context to handler Oct 26, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 26, 2025

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5601

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5601

@tanstack/eslint-plugin-router

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

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5601

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5601

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5601

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5601

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5601

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5601

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5601

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5601

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5601

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5601

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5601

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5601

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5601

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5601

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5601

commit: 5a8eae6

@schiller-manuel schiller-manuel merged commit 41cc7e1 into TanStack:main Oct 26, 2025
6 checks passed
naoya7076 pushed a commit to naoya7076/router that referenced this pull request Feb 15, 2026
Co-authored-by: Samy Alzahrani <samyalzahrani@MacBook-Air.local>
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.

The behavior of types and the actual object for context does not match

2 participants