fix: register createServerFn fetcher as serializable #5268
main fromrefs/pull/5268/head·merged by schiller-manuel(GitHub profile, opens in a new tab) Summary by CodeRabbit#
New Features
- Server function objects now include a standardized marker flag for reliable detection by client code and tooling.
Refactor
- Serializer type system refined and expanded in the public API to improve handling of serializable shapes.
Tests
- Added type-level tests to confirm the new server function marker and to validate serializability.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-client-core
View your CI Pipeline Execution ↗ for commit eca3de42a8b210f7e5314c357eb57817a304a7bf
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded 1m 15s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 2s View ↗
☁️ Nx Cloud last updated this comment at
2025-09-27 22:02:04UTCMore templates
- tanstack-router-solid-example-basic
- 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-streaming-file-based
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-solid-start-example-bare
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-static
- 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-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- 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@5268@tanstack/directive-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5268@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5268@tanstack/history
npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5268@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5268@tanstack/react-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5268@tanstack/react-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5268@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5268@tanstack/react-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5268@tanstack/react-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5268@tanstack/react-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5268@tanstack/router-cli
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5268@tanstack/router-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5268@tanstack/router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5268@tanstack/router-devtools-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5268@tanstack/router-generator
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5268@tanstack/router-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5268@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5268@tanstack/router-utils
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5268@tanstack/router-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5268@tanstack/server-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5268@tanstack/solid-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5268@tanstack/solid-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5268@tanstack/solid-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5268@tanstack/solid-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5268@tanstack/solid-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5268@tanstack/start-client-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5268@tanstack/start-plugin-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5268@tanstack/start-server-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5268@tanstack/start-static-server-functions
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5268@tanstack/start-storage-context
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5268@tanstack/valibot-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5268@tanstack/virtual-file-routes
npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5268@tanstack/zod-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5268commit:
eca3de4github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-core
schiller-manuel(GitHub profile, opens in a new tab) changed the title
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between d02c2714a0dd92d43691e7848d2e6b863a07fbb2 and 0272efbc2341af6a58fcfd2b7b388f5b0e756e1e.
📒 Files selected for processing (5)
packages/router-core/src/index.ts(1 hunks)packages/router-core/src/ssr/serializer/transformer.ts(1 hunks)packages/start-client-core/src/createServerFn.ts(2 hunks)packages/start-client-core/src/createStart.ts(2 hunks)packages/start-client-core/src/tests/createServerFn.test-d.ts(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/start-client-core/src/createServerFn.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
packages/router-core/src/index.tspackages/router-core/src/ssr/serializer/transformer.tspackages/start-client-core/src/createStart.tspackages/start-client-core/src/tests/createServerFn.test-d.ts
packages/router-core/**
📄 CodeRabbit inference engine (AGENTS.md)
Keep framework-agnostic core router logic in packages/router-core/
Files:
packages/router-core/src/index.tspackages/router-core/src/ssr/serializer/transformer.ts
packages/{*-start,start-*}/**
📄 CodeRabbit inference engine (AGENTS.md)
Name and place Start framework packages under packages/-start/ or packages/start-/
Files:
packages/start-client-core/src/createStart.tspackages/start-client-core/src/tests/createServerFn.test-d.ts
🧬 Code graph analysis (3)
packages/router-core/src/ssr/serializer/transformer.ts (1)
packages/router-core/src/index.ts (3)
DefaultSerializable(424-424)SerializableExtensions(423-423)Serializable(425-425)
packages/start-client-core/src/createStart.ts (3)
packages/router-core/src/index.ts (1)
SerializableExtensions(423-423)
packages/router-core/src/ssr/serializer/transformer.ts (1)
SerializableExtensions(22-22)
packages/start-client-core/src/index.tsx (1)
TSS_SERVER_FUNCTION(86-86)
packages/start-client-core/src/tests/createServerFn.test-d.ts (2)
packages/start-client-core/src/createServerFn.ts (1)
createServerFn(51-170)
packages/start-client-core/src/index.tsx (2)
createServerFn(16-16)TSS_SERVER_FUNCTION(86-86)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test
packages/start-client-core/src/createStart.ts line 2@@ -1 +1,2 @@11 import { createMiddleware } from './createMiddleware'2+import type { TSS_SERVER_FUNCTION } from './constants'⚠️ Potential issue | 🔴 Critical
Import
TSS_SERVER_FUNCTIONas a value so the computed property type-checks.import typeremoves the runtime symbol, so when this module augmentation evaluates[TSS_SERVER_FUNCTION]there is no corresponding value and the file fails to compile ('TSS_SERVER_FUNCTION' only refers to a type, but is being used as a value here.). Pull the symbol in as a normal import (and keep using it in the ambient declaration) so the unique symbol is available.-import type { TSS_SERVER_FUNCTION } from './constants' +import { TSS_SERVER_FUNCTION } from './constants'Also applies to: 120-122
🤖 Prompt for AI Agents
In packages/start-client-core/src/createStart.ts around lines 2 and also lines 120-122, the symbol TSS_SERVER_FUNCTION is currently imported with "import type" so it is erased at runtime and the module augmentation that uses [TSS_SERVER_FUNCTION] fails to compile; change the import to a normal value import (remove the "type" qualifier) so the unique symbol/value is present at runtime and keep using that same identifier in the ambient declaration to allow the computed property to type-check and compile.
Sign in to join this conversation.
Walkthrough#
Adds a TSS_SERVER_FUNCTION symbol flag to client fetcher types and tests; refactors router-core serializer typing by introducing DefaultSerializable and SerializableExtensions and redefining Serializable; and re-exports those serializer types from router-core's public API.
Changes#
packages/start-client-core/src/createServerFn.ts,packages/start-client-core/src/createStart.tsTSS_SERVER_FUNCTION;FetcherBasegains a computed property[TSS_SERVER_FUNCTION]: true; module augmentation updated to addSerializableExtensionswithserverFn: { [TSS_SERVER_FUNCTION]: true }.packages/start-client-core/src/tests/createServerFn.test-d.tsTSS_SERVER_FUNCTIONand two type tests: one asserting created server functions expose theTSS_SERVER_FUNCTIONsymbol with valuetrue, and one exercising fetcher serializability.packages/router-core/src/index.ts./ssr/serializer/transformer:SerializableExtensions,DefaultSerializable, andSerializable.packages/router-core/src/ssr/serializer/transformer.tsSerializableunion with a mapping-based system: addsDefaultSerializableinterface (members:number,string,boolean,null,undefined,bigint,Date),SerializableExtensionsextending it, and definesSerializable = SerializableExtensions[keyof SerializableExtensions].e2e/react-start/server-functions/src/routes/middleware/send-serverFn.tsxanycast when sending a server function reference; uses inferred typing instead (no runtime behavior change).Sequence Diagram(s)#
(Skipped — changes are type/API surface updates without runtime control-flow modifications.)
Estimated code review effort#
🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem#
Pre-merge checks and finishing touches#
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 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 0272efbc2341af6a58fcfd2b7b388f5b0e756e1e and eca3de42a8b210f7e5314c357eb57817a304a7bf.
📒 Files selected for processing (1)
e2e/react-start/server-functions/src/routes/middleware/send-serverFn.tsx(1 hunks)🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Files:
e2e/react-start/server-functions/src/routes/middleware/send-serverFn.tsx**/src/routes/**
📄 CodeRabbit inference engine (AGENTS.md)
Files:
e2e/react-start/server-functions/src/routes/middleware/send-serverFn.tsxe2e/**
📄 CodeRabbit inference engine (AGENTS.md)
Files:
e2e/react-start/server-functions/src/routes/middleware/send-serverFn.tsx⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (1)
Comment `@coderabbitai help` to get the list of available commands and usage tips.