Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby): Add back missing partial hydration error handling change #36676

Merged
merged 1 commit into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/gatsby-cli/src/structured-errors/error-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
29 changes: 13 additions & 16 deletions packages/gatsby/src/commands/build-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down