You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
When using @tanstack/start server functions, any thrown error except redirects/notFound is always turned into an HTTP 500, even if you previously called setResponseStatus(code). Conversely, returning an Error instance respects the status but serializes to an empty payload. This makes it impossible to send rich error details (e.g. validation failures) with the proper HTTP status.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
When using
@tanstack/start
server functions, any thrown error exceptredirects
/notFound
is always turned into an HTTP 500, even if you previously calledsetResponseStatus(code)
. Conversely, returning anError
instance respects the status but serializes to an empty payload. This makes it impossible to send rich error details (e.g. validation failures) with the proper HTTP status.Reproduction:
Wrap your RPC call in a middleware that does:
Observe on the client:
{ message, stack }
, not theerrors
object.Change to returning instead of throwing:
Observe:
{ result: { $undefined: 0 }, error: { $undefined: 0 }, … }
.Expected behavior:
name
,message
,errors
, etc.) in a stable format.Possible solutions:
setResponseStatus(code)
on thrown errors (not just onResponse
instances).throw errorWithStatus(payload, status)
analogous tojson()
/redirect()
/notFound()
.HttpError
) with astatus
property that the runtime will honor.Context:
@tanstack/react-start
+@tanstack/react-router
(v1.128.3).setResponseStatus(code)
before throwing aFormError
.notFound()
already work as expected.Thanks! 🙏
Beta Was this translation helpful? Give feedback.
All reactions