Skip to content

Cannot use connectRPC call inside tanstack start server function #6141

Closed

Description

@Quadrubo

Which project does this relate to?

Router

Describe the bug

I'm having some typing issues with using connectrpc in tanstack start.
I have the following server function.

export const login = createServerFn()
  .validator((data: unknown) => {
    return data as LoginRequest
  })
  .handler(async ({ data }) => {
    const authClient = await createGRPCClient(AuthService)
    return await authClient.login({
      email: data.email,
      password: data.password,
    })
  })

This results in this typing error.

TS2345: Argument of type

({data}: ServerFnCtx<Method, "data", undefined, (data: unknown) => LoginRequest>) => Promise<LoginResponse>

is not assignable to parameter of type

ServerFn<Method, "data", undefined, (data: unknown) => LoginRequest, LoginResponse>

Type 'Promise<LoginResponse>' is not assignable to type 'Promise<{ readonly $typeName: "api.auth.v1.LoginResponse"; $unknown?: { readonly no: number; readonly wireType: WireType; readonly data: { [x: number]: number; readonly BYTES_PER_ELEMENT: number; ... 32 more ...; readonly [Symbol.toStringTag]: "Uint8Array"; }; }[] | undefined; jwt: string; }> | { ...; }'.

Type 'Promise<LoginResponse>' is not assignable to type 'Promise<{ readonly $typeName: "api.auth.v1.LoginResponse"; $unknown?: { readonly no: number; readonly wireType: WireType; readonly data: { [x: number]: number; readonly BYTES_PER_ELEMENT: number; ... 32 more ...; readonly [Symbol.toStringTag]: "Uint8Array"; }; }[] | undefined; jwt: string; }>'.

Type 'LoginResponse' is not assignable to type '{ readonly $typeName: "api.auth.v1.LoginResponse"; $unknown?: { readonly no: number; readonly wireType: WireType; readonly data: { [x: number]: number; readonly BYTES_PER_ELEMENT: number; ... 32 more ...; readonly [Symbol.toStringTag]: "Uint8Array"; }; }[] | undefined; jwt: string; }'.

Types of property $unknown are incompatible.

Type 'UnknownField[] | undefined' is not assignable to type '{ readonly no: number; readonly wireType: WireType; readonly data: { [x: number]: number; readonly BYTES_PER_ELEMENT: number; readonly buffer: { readonly byteLength: number; slice: "Function is not serializable"; readonly [Symbol.toStringTag]: "ArrayBuffer"; } | { ...; }; ... 31 more ...; readonly [Symbol.toStringTa...'.

Type 'UnknownField[]' is not assignable to type '{ readonly no: number; readonly wireType: WireType; readonly data: { [x: number]: number; readonly BYTES_PER_ELEMENT: number; readonly buffer: { readonly byteLength: number; slice: "Function is not serializable"; readonly [Symbol.toStringTag]: "ArrayBuffer"; } | { ...; }; ... 31 more ...; readonly [Symbol.toStringTa...'.

Type 'UnknownField' is not assignable to type '{ readonly no: number; readonly wireType: WireType; readonly data: { [x: number]: number; readonly BYTES_PER_ELEMENT: number; readonly buffer: { readonly byteLength: number; slice: "Function is not serializable"; readonly [Symbol.toStringTag]: "ArrayBuffer"; } | { ...; }; ... 31 more ...; readonly [Symbol.toStringTa...'.

The types of data.buffer are incompatible between these types.

Type ArrayBufferLike is not assignable to type

{

    readonly byteLength: number;

    slice: "Function is not serializable";

    readonly [Symbol.toStringTag]: "ArrayBuffer";

} | {

    readonly byteLength: number;

    slice: "Function is not serializable";

    readonly [Symbol.toStringTag]: "SharedArrayBuffer";

}

Type ArrayBuffer is not assignable to type

{

    readonly byteLength: number;

    slice: "Function is not serializable";

    readonly [Symbol.toStringTag]: "ArrayBuffer";

} | {

    readonly byteLength: number;

    slice: "Function is not serializable";

    readonly [Symbol.toStringTag]: "SharedArrayBuffer";

}

Type ArrayBuffer is not assignable to type

{

    readonly byteLength: number;

    slice: "Function is not serializable";

    readonly [Symbol.toStringTag]: "ArrayBuffer";

}

Types of property slice are incompatible.

Type

(begin?: number | undefined, end?: number | undefined) => ArrayBuffer

is not assignable to type "Function is not serializable"

I have also tried using the create function but this produces the same error.

Also see the issue here: bufbuild/protobuf-es#1232
Using json_types is not a proper solution as important type information gets lost

Your Example Website or App

https://github.com/Quadrubo/protoc-arraybuffer-repro

Steps to Reproduce the Bug or Issue

Follow the steops in this repro repo: https://github.com/Quadrubo/protoc-arraybuffer-repro

Expected behavior

I expect to receive no type errors and be able to use server functions like normal.

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.141.7
  • Bundler: vite
  • Bundler Version: 7.3.0

Additional context

No response

Activity

  1. coderabbitai commented on Dec 18, 2025

    @coderabbitai
    Contributor

    📝 CodeRabbit Plan Mode

    Generate an implementation plan and prompts that you can use with your favorite coding agent.

    • Create Plan
    Examples

    🔗 Similar Issues

    Possible Duplicates

    🔗 Related PRs

    #5268 - fix: register createServerFn fetcher as serializable [merged]
    #5276 - fix: raw response handling [merged]
    #5482 - fix: parent param types in server routes [merged]
    #5501 - fix: undefined / null serialization [merged]
    #5720 - fix: Make serverFn union response type distributive [merged]

    👤 Suggested Assignees

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord or schedule a call!

  2. Quadrubo commented on Mar 8, 2026

    @Quadrubo
    Author

    Could I get some answer here, would really like to use tanstack start but this prevents me from using it.

  3. schiller-manuel commented on Mar 9, 2026

    @schiller-manuel
    Collaborator

    the data types contains unserializable properties, see "Function is not serializable"

  4. schiller-manuel commented on Apr 30, 2026

    @schiller-manuel
    Collaborator

    you can now opt out of the type level serialization check via createServerFn({ strict: false }) which will also allow you to have unknown in there

    see #7277

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions