-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Description
I'm using React Router as a...
framework
Reproduction
behaviour observed with both <Await>
and use()
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:
export function loader({ params }: Route.LoaderArgs) {
let getItem = async () => {
await new Promise((resolve) => setTimeout(resolve, 400));
if (params.itemId !== '1') {
throw { code: 'NOT_FOUND' };
}
return { name: 'hello' };
};
return { item: getItem() };
}
I would expect the ErrorBoundary to receive the custom object { code: 'NOT_FOUND' };
Actual Behavior
in the stackblitz example click item stream invalid link
opening a page using client navigation (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 opening the same page with full refresh/ server render, produces the expected result: