Skip to content

Commit

Permalink
Handle empty pageData during HMR (vercel/turborepo#3412)
Browse files Browse the repository at this point in the history
Our `pageData` HMR process treated an undefined response as an error condition, but if the page doesn't have a `getXyzProps` exported method, then this is the default response. This prevented us from having any pages without page props.

The new code just sends down an empty object, which seems to work for establishing the connection. HMR updates are sent down (and seem to trigger restarts, at least from what I tested with `getStaticProps`).

Fixes WEB-445
  • Loading branch information
jridgewell authored Jan 21, 2023
1 parent 8e202bb commit 1987039
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/next-core/js/src/internal/page-server-handler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ export default function startHandler({
}
}

const res = await runOperation(renderData);
let res = await runOperation(renderData);

if (isDataReq) {
if (res === undefined) {
throw new Error("no data result returned");
// Page data is only returned if the page had getXxyProps.
res = {};
}
ipc.send({
type: "result",
Expand Down

0 comments on commit 1987039

Please sign in to comment.