fix(start-server-core): deserialize tss context when using formdata #5935
main fromrefs/pull/5935/head·merged by schiller-manuel(GitHub profile, opens in a new tab) Fixes https://github.com/TanStack/router/issues/5913 where the client TSS_CONTEXT is not deserialized when using formdata
Summary by CodeRabbit#
New Features
- Added a FormData context test route with a UI to invoke two server actions and view results.
Refactor
- Improved server-side context deserialization for more reliable context handling (no public API changes).
Tests
- Added end-to-end tests verifying context propagation for FormData and simple server actions.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-server-core
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/start-server-core/src/server-functions-handler.ts (1)
95-95: Consider logging deserialization errors for debugging.The empty catch block silently swallows errors during context deserialization. While this provides fail-safe behavior (falling back to the original context), adding a debug log would aid troubleshooting.
Apply this diff to add error logging:
- } catch {} + } catch (error) { + console.debug('Failed to deserialize FormData context:', error) + }📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between bc79c9783b86e92f4eb5749c9a96d526f86bd54b and 128800ab96662f5342b79452b14587596741b547.
📒 Files selected for processing (1)
packages/start-server-core/src/server-functions-handler.ts(1 hunks)
🔇 Additional comments (1)
packages/start-server-core/src/server-functions-handler.ts (1)
91-93: LGTM! Proper deserialization with seroval plugins.The use of
fromJSONwith seroval plugins correctly deserializes the context, enabling support for complex types (Dates, Maps, Sets, etc.) thatJSON.parsealone cannot handle. This brings the FormData context deserialization in line with theparsePayloadfunction used elsewhere in the code.thanks! we should also add a testcase to the e2e server functions test
thanks! we should also add a testcase to the e2e server functions test
Added a test similar to my reproducer and ran it. Seems to work along with the other tests.
schiller-manuel(GitHub profile, opens in a new tab) changed the title
View your CI Pipeline Execution ↗ for commit 72c64619400586214a76ed6753aa2eda85992c03
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded 7m 18s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 23s View ↗
☁️ Nx Cloud last updated this comment at
2025-11-22 00:05:25UTCAnything else I need to add?
More templates
- tanstack-router-solid-example-authenticated-routes
- tanstack-router-solid-example-authenticated-routes-firebase
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-default-search-params
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-basic-virtual-file-based
- tanstack-router-solid-example-basic-virtual-inside-file-based
- tanstack-router-solid-example-deferred-data
- tanstack-router-solid-i18n-paraglide
- tanstack-router-solid-example-kitchen-sink
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-kitchen-sink-solid-query
- tanstack-router-solid-example-kitchen-sink-solid-query-file-based
- tanstack-router-solid-example-large-file-based
- tanstack-router-solid-example-location-masking
- tanstack-router-solid-example-navigation-blocking
- tanstack-router-solid-example-quickstart
- tanstack-router-solid-example-quickstart-esbuild-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-router-solid-example-quickstart-rspack-file-based
- tanstack-router-solid-example-quickstart-webpack-file-based
- router-solid-mono-simple
- router-solid-mono-simple-lazy
- router-solid-monorepo-solid-query
- tanstack-router-solid-example-scroll-restoration
- tanstack-solid-router-search-validator-adapters
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-auth
- tanstack-solid-start-example-basic-cloudflare
- tanstack-solid-start-example-basic-netlify
- tanstack-solid-start-example-basic-nitro
- tanstack-start-example-basic-solid-query
- tanstack-solid-start-example-basic-static
- tanstack-solid-start-bun-hosting
- tanstack-solid-start-example-convex-better-auth
- tanstack-solid-start-example-counter
- tanstack-solid-start-i18n-paraglide
- tanstack-solid-start-example-large
- tanstack-solid-start-streaming-data-from-server-functions
- tanstack-solid-start-example-supabase-basic
- tanstack-solid-start-tailwind-v4
- tanstack-router-solid-example-view-transitions
- tanstack-router-solid-example-with-framer-motion
- tanstack-router-solid-example-with-trpc
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-i18n-paraglide
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-clerk-basic
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-streaming-data-from-server-functions
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
@tanstack/arktype-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5935@tanstack/directive-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5935@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5935@tanstack/history
npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5935@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5935@tanstack/react-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5935@tanstack/react-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5935@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5935@tanstack/react-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5935@tanstack/react-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5935@tanstack/react-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5935@tanstack/router-cli
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5935@tanstack/router-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5935@tanstack/router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5935@tanstack/router-devtools-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5935@tanstack/router-generator
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5935@tanstack/router-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5935@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5935@tanstack/router-utils
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5935@tanstack/router-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5935@tanstack/server-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5935@tanstack/solid-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5935@tanstack/solid-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5935@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@5935@tanstack/solid-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5935@tanstack/solid-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5935@tanstack/solid-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5935@tanstack/start-client-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5935@tanstack/start-plugin-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5935@tanstack/start-server-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5935@tanstack/start-static-server-functions
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5935@tanstack/start-storage-context
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5935@tanstack/valibot-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5935@tanstack/virtual-file-routes
npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5935@tanstack/zod-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5935commit:
72c6461
Sign in to join this conversation.
Walkthrough#
Replaces ad-hoc JSON parsing of a serialized middleware context with seroval plugin-based deserialization in the server handler, and adds a new FormData-driven test route + UI and an e2e test that verifies client middleware context propagation when sending FormData.
Changes#
packages/start-server-core/src/server-functions-handler.tsJSON.parse+ shallow merge withseroval.fromJSON(with plugins) to deserializeserializedContextintodeserializedContext, then merge intoparams.contextonly if non-null. No public signature changes.e2e/react-start/server-functions/src/routes/formdata-context.tsxformDataWithContextFn,simpleTestFn) that read middleware context, and UI controls to invoke and display results.e2e/react-start/server-functions/src/routeTree.gen.tsFormdataContextRouteand wire it into all route mapping exports and TanStack Router module declarations.e2e/react-start/server-functions/tests/server-functions.spec.tsSequence Diagram(s)#
Estimated code review effort#
🎯 3 (Moderate) | ⏱️ ~20 minutes
seroval.fromJSONusage and plugin list match serialization encoding.Possibly related PRs#
server-functions-handler.ts; touches the same deserialization area.handleServerActioninserver-functions-handler.ts(raw-response/header handling), overlapping the same handler surface.Suggested reviewers#
Poem#
Pre-merge checks and finishing touches#
❌ Failed checks (1 warning)
@coderabbitai generate docstringsto improve docstring coverage.✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between bbce531be34b05ef195ad47af387def7d0eb1946 and 72c64619400586214a76ed6753aa2eda85992c03.
📒 Files selected for processing (3)
e2e/react-start/server-functions/src/routes/formdata-context.tsx(1 hunks)e2e/react-start/server-functions/tests/server-functions.spec.ts(1 hunks)packages/start-server-core/src/server-functions-handler.ts(1 hunks)🚧 Files skipped from review as they are similar to previous changes (3)
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