Skip to content

Commit 5cee3c2

Browse files
committed
Recover from SSR error in Flight fixture
1 parent c1fd2a9 commit 5cee3c2

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

fixtures/flight/server/global.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,19 @@ app.all('/', async function (req, res, next) {
174174
const {pipe} = renderToPipeableStream(React.createElement(Root), {
175175
bootstrapScripts: mainJSChunks,
176176
formState: formState,
177+
onShellReady() {
178+
pipe(res);
179+
},
180+
onShellError(error) {
181+
const {pipe: pipeError} = renderToPipeableStream(
182+
React.createElement('html', null, React.createElement('body')),
183+
{
184+
bootstrapScripts: mainJSChunks,
185+
}
186+
);
187+
pipeError(res);
188+
},
177189
});
178-
pipe(res);
179190
} catch (e) {
180191
console.error(`Failed to SSR: ${e.stack}`);
181192
res.statusCode = 500;

fixtures/flight/server/region.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,8 @@ app.get('/', async function (req, res) {
103103
});
104104

105105
app.post('/', bodyParser.text(), async function (req, res) {
106-
const {
107-
renderToPipeableStream,
108-
decodeReply,
109-
decodeReplyFromBusboy,
110-
decodeAction,
111-
decodeFormState,
112-
} = await import('react-server-dom-webpack/server');
106+
const {decodeReply, decodeReplyFromBusboy, decodeAction, decodeFormState} =
107+
await import('react-server-dom-webpack/server');
113108
const serverReference = req.get('rsc-action');
114109
if (serverReference) {
115110
// This is the client-side case

0 commit comments

Comments
 (0)