-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
throwing object from loader behaves differently when streaming #12676
Comments
https://react.dev/reference/react/use the promise's |
Thanks to be clear I wasn’t trying to get the http status code to be 404 as I am aware it’s too late to change the response headers at that point. I want to have a code on the client side so I can show a better error message. My example would have been better/clearer if it was just
|
have updated the example and description to be clearer |
Have you tried throwing an object of type
In my opinion the best thing would be to add an additional PS. https://reactrouter.com/how-to/error-boundary#2-write-a-bug
This page makes me think if this is bug?? |
the docs also specifically say throwing for not found is recommended https://reactrouter.com/how-to/error-boundary#3-throw-data-in-loadersactions |
Aren't you basically returning a deferred response? In that case you'll have to handle the errors from it the within the |
I tried that doesn't make a difference. As per docs |
I'm using React Router as a...
framework
Reproduction
behaviour observed with both
<Await>
anduse()
using
use
hook:https://stackblitz.com/edit/stackblitz-webcontainer-api-starter-gdwvvw2y?file=app%2Froutes%2Fitem-stream.tsx
using
Await
component:https://stackblitz.com/edit/stackblitz-webcontainer-api-starter-sn1xvkxt?file=app%2Froutes%2Fitem-stream.tsx
Expected Behavior
When defining a loader that returns a promise that can reject with a custom object:
I would expect the ErrorBoundary to receive the custom object
{ code: 'NOT_FOUND' };
in the stackblitz example click item invalid link, for expected behaviour
Actual Behavior
opening a page (via a link) that throws from a streamed promise the ErrorBoundary does not receive the custom object but instead receives
Error: An unknown error occurred
however when you refresh the page in stackblitz it produces the expected result:
in the stackblitz example click item stream invalid link
The text was updated successfully, but these errors were encountered: