Replies: 2 comments 7 replies
-
I would like to understand the problem better. It feels like this should be solved at the low level "minimal" API, not pages. Is it only about customizing
so, you want to return something like |
Beta Was this translation helpful? Give feedback.
-
I wonder if it would be useful to have a way to tap into the react-dom/server.edge renderToReadableStream onError when it is run in a react-server environment. https://react.dev/reference/react-dom/server/renderToReadableStream#logging-crashes-on-the-server I'm not sure if React has docs on the react-dom-server-webpack renderToReadableStream - but I see it has a third options param that seems to take an onError callback. These docs say to wrap renderToReadableStream in a try/catch block for errors that happen outside a Suspense boundary. https://react.dev/reference/react-dom/server/renderToReadableStream#recovering-from-errors-inside-the-shell I'm trying to follow what happens in the waku handler middleware... the renderToReadableStream promise gets passed to the streamFromPromise util which has a try/catch block and calls the error method on the stream. With Waku server, I think the intent is that those errors on the body stream would trigger the Hono server onError handler? https://hono.dev/docs/api/exception#handling-httpexception I am enhancing hono from waku config with an onError handler that looks at the request url. I have it look at I also see that React documents Suspense as the way to handle server errors. The server should render the Suspense fallback on error. And then the client would hit the same error on hydration which would then get trapped by the nearest error boundary. It's great that you got react-error-boundary working "out of the box" from npm. https://react.dev/reference/react-dom/server/renderToReadableStream#recovering-from-errors-outside-the-shell I wonder if our default create-waku template should include an error boundary. The default |
Beta Was this translation helpful? Give feedback.
-
I'm trying to understand how to gracefully handle exceptions raised on the server.
This document suggests that Suspense components can act as error boundaries for SSR - https://github.com/reactjs/rfcs/blob/main/text/0215-server-errors-in-react-18.md
It would be nice to additionally register a fallback component that would be rendered instead of the
error.toString()
.I see that both RSC and SSR waku middleware have this in a catch block:
Maybe if I add middleware that runs after the other renderers, I can see if ctx.res is an error response and update the rendered body.
If I can create unlinked router entries for my error pages, then my middleware could use the rsc or ssr renderers to render one of those entries.
Maybe the exported getConfig() for pages could return the name of a fallback error entry point to use if an exception is hit while rendering that page?
Beta Was this translation helpful? Give feedback.
All reactions