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:
- When the response contains header value
Content-Type: 'application/json', the result of the server function when calling from client would be undefined
- 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#
- Create a server function
serverFn
- Return
new Response with request body is something like new Blob([JSON.stringify({ a: 1 })])
- Set the header value of the new Response to
Content-Type: 'application/json'
- Calling the server function
serverFn from client code, observe the browser console
- It shows
undefined
Expected behavior#
- The server function should return
Response
- 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