Skip to content
Source
Sign inSign up
TanStack/router

fix: register createServerFn fetcher as serializable #5268

Mergedschiller-manuel(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/5268/headmerged 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. 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

      Cohort / File(s)Summary
      Client: server fn symbol & types
      packages/start-client-core/src/createServerFn.ts, packages/start-client-core/src/createStart.ts
      Added import/usage of TSS_SERVER_FUNCTION; FetcherBase gains a computed property [TSS_SERVER_FUNCTION]: true; module augmentation updated to add SerializableExtensions with serverFn: { [TSS_SERVER_FUNCTION]: true }.
      Client: tests
      packages/start-client-core/src/tests/createServerFn.test-d.ts
      Adds import of TSS_SERVER_FUNCTION and two type tests: one asserting created server functions expose the TSS_SERVER_FUNCTION symbol with value true, and one exercising fetcher serializability.
      Router-core: public exports
      packages/router-core/src/index.ts
      Re-exports three types from ./ssr/serializer/transformer: SerializableExtensions, DefaultSerializable, and Serializable.
      Router-core: serializer typing changes
      packages/router-core/src/ssr/serializer/transformer.ts
      Replaces flat Serializable union with a mapping-based system: adds DefaultSerializable interface (members: number, string, boolean, null, undefined, bigint, Date), SerializableExtensions extending it, and defines Serializable = SerializableExtensions[keyof SerializableExtensions].
      E2E: minor typing removal
      e2e/react-start/server-functions/src/routes/middleware/send-serverFn.tsx
      Removed an explicit any cast 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

      A twitch of nose, a tiny sign, I mark the fetcher — symbol fine. Types reshaped, the map’s brand-new line, I hop through tests and leave a sign. Carrots for merges, code tastes divine! 🥕

      Pre-merge checks and finishing touches

      ✅ Passed checks (3 passed)
      Check nameStatusExplanation
      Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title Check✅ PassedThe title “fix: register createServerFn fetcher as serializable” succinctly describes the core purpose of the changeset—ensuring that the createServerFn fetcher is marked serializable—and uses clear, imperative phrasing without extraneous details. It accurately reflects the main objective of the pull request and omits irrelevant noise like file lists or broad generic terms. As such, it provides immediate clarity to reviewers scanning the PR history.
      Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.
      ✨ Finishing touches
      • 📝 Generate Docstrings
        🧪 Generate unit tests
      • Create PR with unit tests
      • Post copyable unit tests in a comment
      • Commit unit tests in branch `serverfn-serialization`

      📜 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)

      Use TypeScript in strict mode with extensive type safety across the codebase

      Files:

      • e2e/react-start/server-functions/src/routes/middleware/send-serverFn.tsx
      **/src/routes/**

      📄 CodeRabbit inference engine (AGENTS.md)

      Place file-based routes under src/routes/ directories

      Files:

      • e2e/react-start/server-functions/src/routes/middleware/send-serverFn.tsx
      e2e/**

      📄 CodeRabbit inference engine (AGENTS.md)

      Store end-to-end tests under the e2e/ directory

      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)
      • GitHub Check: Test
      • GitHub Check: Preview
      🔇 Additional comments (1)
      e2e/react-start/server-functions/src/routes/middleware/send-serverFn.tsx (1)

      9-9: Type assertion removal improves safety without regressions.

      With the new server-function serializable marker the inference now passes without the as any, so keeping barFn strongly typed in the context is the right move. This keeps the middleware honest and ready to surface future typing issues.


      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-client-core

    3. View your CI Pipeline Execution ↗ for commit eca3de42a8b210f7e5314c357eb57817a304a7bf

      CommandStatusDurationResult
      nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded1m 15sView ↗
      nx run-many --target=build --exclude=examples/*...✅ Succeeded2sView ↗

      ☁️ Nx Cloud last updated this comment at 2025-09-27 22:02:04 UTC

    4. More templates

      @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@5268

      commit: eca3de4

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

    6. 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.ts
      • packages/router-core/src/ssr/serializer/transformer.ts
      • packages/start-client-core/src/createStart.ts
      • packages/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.ts
      • packages/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.ts
      • packages/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_FUNCTION as a value so the computed property type-checks.

      import type removes 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.