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.04k stars 618 forks source link

Start: server functions can't serialize error objects #2535

Open nekochan0122 opened 1 week ago

nekochan0122 commented 1 week ago

Which project does this relate to?

Start

Describe the bug

https://discord.com/channels/719702312431386674/1238170697650405547/1295132419812233226

Your Example Website or App

https://github.com/nekochan0122/start-todolist-server-fn

Steps to Reproduce the Bug or Issue

  1. copy .env.example to .env
  2. pnpm db:push
  3. pnpm db:generate
  4. pnpm dev
  5. try to create same todo and see the error in console

Expected behavior

Error objects should be able to serialize.

Screenshots or Videos

No response

Platform

Additional context

No response

schiller-manuel commented 1 week ago

if an Error is thrown, it can't be serialized using JSON.stringify

this is what happens currently: https://github.com/TanStack/router/blob/ed07f048a8597858a2bff8b4a558bd68760edb15/packages/start/src/client-runtime/fetcher.tsx#L138-L147