Repository navigation
Cannot use connectRPC call inside tanstack start server function #6141
Copy link
Copy link
Closed
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
coderabbitai commentedon Dec 18, 2025
📝 CodeRabbit Plan Mode
Generate an implementation plan and prompts that you can use with your favorite coding agent.
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:💬 Have feedback or questions? Drop into our discord or schedule a call!
Quadrubo commentedon Mar 8, 2026
Could I get some answer here, would really like to use tanstack start but this prevents me from using it.
schiller-manuel commentedon Mar 9, 2026
the data types contains unserializable properties, see "Function is not serializable"
schiller-manuel commentedon Apr 30, 2026
you can now opt out of the type level serialization check via
createServerFn({ strict: false })which will also allow you to haveunknownin theresee #7277