Skip to content

Commit

Permalink
feat(react-server): trigger error overlay on server error
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Apr 8, 2024
1 parent 937bade commit 41006f9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/react-server/src/entry/react-server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ const reactServerOnError: RenderToReadableStreamOptions["onError"] = (
});
if (!(error instanceof ReactServerDigestError)) {
console.error("[react-server:renderToReadableStream]", error);
if (import.meta.env.DEV && error instanceof Error) {
__global.dev.server.hot.send({
type: "error",
err: {
message: error.message,
stack: error.stack ?? "",
},
});
}
}
const serverError =
error instanceof ReactServerDigestError
Expand Down
9 changes: 9 additions & 0 deletions packages/react-server/src/entry/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ export async function renderHtml(
debug("renderToReadableStream", { error, errorInfo });
if (!getErrorContext(error)) {
console.error("[react-dom:renderToReadableStream]", error);
if (import.meta.env.DEV && error instanceof Error) {
__global.dev.server.hot.send({
type: "error",
err: {
message: error.message,
stack: error.stack ?? "",
},
});
}
}
},
});
Expand Down

0 comments on commit 41006f9

Please sign in to comment.