mirror of
https://github.com/facebook/react.git
synced 2026-02-23 20:23:02 +00:00
Recover from SSR error in Flight fixture (#28368)
If an error happens before the shell, we need to handle it. In this case we choose the strategy of rendering a blank document and client rendering the app. Which will intentionally have a hydration mismatch.
This commit is contained in:
committed by
GitHub
parent
9444c51c7e
commit
017397d7d3
@@ -174,8 +174,19 @@ app.all('/', async function (req, res, next) {
|
||||
const {pipe} = renderToPipeableStream(React.createElement(Root), {
|
||||
bootstrapScripts: mainJSChunks,
|
||||
formState: formState,
|
||||
onShellReady() {
|
||||
pipe(res);
|
||||
},
|
||||
onShellError(error) {
|
||||
const {pipe: pipeError} = renderToPipeableStream(
|
||||
React.createElement('html', null, React.createElement('body')),
|
||||
{
|
||||
bootstrapScripts: mainJSChunks,
|
||||
}
|
||||
);
|
||||
pipeError(res);
|
||||
},
|
||||
});
|
||||
pipe(res);
|
||||
} catch (e) {
|
||||
console.error(`Failed to SSR: ${e.stack}`);
|
||||
res.statusCode = 500;
|
||||
|
||||
@@ -103,13 +103,8 @@ app.get('/', async function (req, res) {
|
||||
});
|
||||
|
||||
app.post('/', bodyParser.text(), async function (req, res) {
|
||||
const {
|
||||
renderToPipeableStream,
|
||||
decodeReply,
|
||||
decodeReplyFromBusboy,
|
||||
decodeAction,
|
||||
decodeFormState,
|
||||
} = await import('react-server-dom-webpack/server');
|
||||
const {decodeReply, decodeReplyFromBusboy, decodeAction, decodeFormState} =
|
||||
await import('react-server-dom-webpack/server');
|
||||
const serverReference = req.get('rsc-action');
|
||||
if (serverReference) {
|
||||
// This is the client-side case
|
||||
|
||||
Reference in New Issue
Block a user