TanStack / router

🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering.
https://tanstack.com/router
MIT License
8.19k stars 649 forks source link

Start: createServerFn cannot return `null` #2776

Open SeanCassiere opened 2 hours ago

SeanCassiere commented 2 hours ago

Which project does this relate to?

Router

Describe the bug

All details are found in this discussion thread on Discord - https://discord.com/channels/719702312431386674/1306957125246914590

The crust of the matter is that you aren't able to return null from a createServerFn call.

const fn = createServerFn().handler(async () => {
    return null
})

await fn(); // undefined

Your Example Website or App

https://discord.com/channels/719702312431386674/1306957125246914590

Steps to Reproduce the Bug or Issue

Create a server function returning null and see that at runtime it does not return the value, instead, it returns undefined.

Expected behavior

The returned null value from the server function should correctly get piped down to the caller.

Screenshots or Videos

No response

Platform

N/A

Additional context

No response

SeanCassiere commented 2 hours ago

Need to investigate the issue.