Skip to content

Server function returns undefined on raw response value #5271

Closed

Description

@TranHHoang

Which project does this relate to?

Start

Describe the bug

Hi, I'm testing with server function returning raw response object and found two issues:

  1. When the response contains header value Content-Type: 'application/json', the result of the server function when calling from client would be undefined
  2. Typing issue when trying to return a raw response from server function
Argument of type '() => Promise<Response>' is not assignable to parameter of type 'ServerFn<Register, Method, undefined, undefined, Response>'.
  Type 'Promise<Response>' is not assignable to type 'ServerFnReturnType<Register, Response>'.
    Type 'Promise<Response>' is not assignable to type 'Promise<{ readonly headers: { append: "Function is not serializable"; delete: "Function is not serializable"; get: "Function is not serializable"; getSetCookie: "Function is not serializable"; ... 6 more ...; [Symbol.iterator]: "Function is not serializable"; }; ... 13 more ...; text: "Function is not serializable";...'.

Your Example Website or App

https://codesandbox.io/p/devbox/composed-middleware-typing-issue-1-132-7-forked-tf7qdv?workspaceId=ws_FVyNhR4d8pZ6SV3c4bTiw7

Steps to Reproduce the Bug or Issue

  1. Create a server function serverFn
  2. Return new Response with request body is something like new Blob([JSON.stringify({ a: 1 })])
  3. Set the header value of the new Response to Content-Type: 'application/json'
  4. Calling the server function serverFn from client code, observe the browser console
  5. It shows undefined

Expected behavior

  1. The server function should return Response
  2. No typing issue

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.132.18
  • OS: macOS/Linux
  • Browser: Chrome
  • Browser Version: [e.g. 91.1]
  • Bundler: [e.g. vite]
  • Bundler Version: [e.g. 7.0.0]

Additional context

No response

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