Throwing error inside Server Function's handler crashes the app
Not sure if I messed up something, but my Tanstack Start app will crash if an error is thrown inside the server function's handler,
Inspired by the doc's example here
My app will crash with the following error
The function is called from a query hook
and the query is called in a loader
Is this expected? I think it works before
Server Functions | TanStack Start React Docs
What are Server Functions? Server functions let you define server-only logic that can be called from anywhere in your application loaders, components, hooks, or other server functions. They run on the...
4 Replies
constant-blue•2mo ago
Call the serverFn with this wrapper: queryFn: () => useServerFn(getRecipeByIdFn)()
continuing-cyanOP•2mo ago
Thanks. This works, but it makes exporting and reusing the queryOptions more annoying tho
not sure if there's a better pattern?
and I will not be able to use the queryOptions in the loader since I need to call useServer hook to pass to the query options
eager-peach•2mo ago
are you using the query integration?
eager-peach•2mo ago
TanStack Query Integration | TanStack Router Docs
[!IMPORTANT] This integration automates SSR dehydration/hydration and streaming between TanStack Router and TanStack Query. If you haven't read the standard guide, start there. What you get Automatic...