From 1987039dfc79fbd8f113278ff88f5555f27db092 Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Sat, 21 Jan 2023 01:47:38 -0500 Subject: [PATCH] Handle empty pageData during HMR (vercel/turbo#3412) 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 --- crates/next-core/js/src/internal/page-server-handler.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/next-core/js/src/internal/page-server-handler.tsx b/crates/next-core/js/src/internal/page-server-handler.tsx index 71fc910f3a620..d61dc414ff308 100644 --- a/crates/next-core/js/src/internal/page-server-handler.tsx +++ b/crates/next-core/js/src/internal/page-server-handler.tsx @@ -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",