Skip to content

Commit

Permalink
Recover from SSR error in Flight fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Feb 18, 2024
1 parent c1fd2a9 commit 86e2f11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 11 additions & 1 deletion fixtures/flight/server/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,18 @@ 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;
Expand Down
1 change: 0 additions & 1 deletion fixtures/flight/server/region.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ app.get('/', async function (req, res) {

app.post('/', bodyParser.text(), async function (req, res) {
const {
renderToPipeableStream,
decodeReply,
decodeReplyFromBusboy,
decodeAction,
Expand Down

0 comments on commit 86e2f11

Please sign in to comment.