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
Attempting to use the <HttpStatusCode code={err.statusCode ?? 500} /> component inside the fallback prop of an <ErrorBoundary /> still results in 200 status. The response is unaffected.
Expected behavior 🤔
The response status should be updated to match the H3Error.statusCode or default to 500.
Steps to reproduce 🕹
Not sure how to create a project on codesandbox to reproduce this, but this should be the relatvent code:
Attempting to handle any page errors by wrapping the file router in an ErrorBoundary. Besides unhandled server errors, I'm also intentionally throwing 404 H3Errors from the RPC server functions when the requested URL params don't point to valid data. Currently, its allowing me to show an error page, but the response status is still 200.
I just added <HttpStatusCode code={500} /> to the default ErrorBoundary component (see PR #1204). After this change, I noticed that it started returning the correct status code, as you can see in this screenshot:
However, I observed that the onBeforeResponse middleware executes before the ErrorBoundary component. This behavior might be related to the issue, and it's possible that an await is missing somewhere, which could explain why it sometimes works correctly.
If the response is streaming then its possible I assume that onBeforeResponse could fire before the ErrorBoundary and the status code would never update. But it shouldn't happen in the synchronous case.
Yeah more specifically. Given the new ErrorBoundary works and I haven't reproduced it locally my suspicion is that this is a streaming response that has already flushed. Please provide a reproduction. Stackblitz should work now or a github repo.
Duplicates
Latest version
Current behavior 😯
Attempting to use the
<HttpStatusCode code={err.statusCode ?? 500} />
component inside the fallback prop of an<ErrorBoundary />
still results in200
status. The response is unaffected.Expected behavior 🤔
The response status should be updated to match the
H3Error.statusCode
or default to500
.Steps to reproduce 🕹
Not sure how to create a project on codesandbox to reproduce this, but this should be the relatvent code:
Context 🔦
Attempting to handle any page errors by wrapping the file router in an ErrorBoundary. Besides unhandled server errors, I'm also intentionally throwing 404 H3Errors from the RPC server functions when the requested URL params don't point to valid data. Currently, its allowing me to show an error page, but the response status is still 200.
Your environment 🌎
The text was updated successfully, but these errors were encountered: