From a62955144f4d369e18402a9c4345f213c3a1d72e Mon Sep 17 00:00:00 2001 From: Ty Hopp Date: Fri, 23 Sep 2022 19:45:02 +0800 Subject: [PATCH] fix(gatsby): Add back missing partial hydration error handling change (#36676) --- .../src/structured-errors/error-map.ts | 2 +- packages/gatsby/src/commands/build-html.ts | 29 +++++++++---------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/packages/gatsby-cli/src/structured-errors/error-map.ts b/packages/gatsby-cli/src/structured-errors/error-map.ts index 4468895c810ec..ec5163c1e6a99 100644 --- a/packages/gatsby-cli/src/structured-errors/error-map.ts +++ b/packages/gatsby-cli/src/structured-errors/error-map.ts @@ -772,7 +772,7 @@ const errors = { "80000": { text: (context): string => stripIndents(`Building partial HTML failed${ - context.path ? ` for path "${context.path}"` : `` + context?.path ? ` for path "${context.path}"` : `` } This can happen if interactive elements like "useEffect", "useState", "createContext" or event handlers are used in a component without declaring the "client export" directive at the top of the file. diff --git a/packages/gatsby/src/commands/build-html.ts b/packages/gatsby/src/commands/build-html.ts index a13696a4da687..2ae559f82012d 100644 --- a/packages/gatsby/src/commands/build-html.ts +++ b/packages/gatsby/src/commands/build-html.ts @@ -463,23 +463,20 @@ const renderPartialHydrationQueue = async ( const sessionId = Date.now() // const { webpackCompilationHash } = store.getState() - try { - await Promise.all( - segments.map(async pageSegment => { - await workerPool.single.renderPartialHydrationProd({ - envVars, - paths: pageSegment, - sessionId, - }) - - if (activity && activity.tick) { - activity.tick(pageSegment.length) - } + // Let the error bubble up + await Promise.all( + segments.map(async pageSegment => { + await workerPool.single.renderPartialHydrationProd({ + envVars, + paths: pageSegment, + sessionId, }) - ) - } catch (e) { - console.log({ e }) - } + + if (activity && activity.tick) { + activity.tick(pageSegment.length) + } + }) + ) } class BuildHTMLError extends Error {