Skip to content

fix: propagate page generateMetadata errors to error boundary#374

Merged
james-elicx merged 1 commit intoj-branch-11from
fix/metadata-error-propagation
Mar 9, 2026
Merged

fix: propagate page generateMetadata errors to error boundary#374
james-elicx merged 1 commit intoj-branch-11from
fix/metadata-error-propagation

Conversation

@james-elicx
Copy link
Copy Markdown
Collaborator

Summary

  • Fixes a regression introduced by the metadata/viewport parallelisation PR (perf: parallelise metadata and viewport resolution #372)
  • Layout generateMetadata() errors are still swallowed (.catch(() => null)) — a layout failing shouldn't crash the page
  • Page generateMetadata() errors now propagate out of buildPageElement() so the caller routes them to the nearest error.tsx or global-error.tsx boundary

Root Cause

The parallelisation PR applied .catch(() => null) to all modules including the page module. This silently swallowed errors thrown by page.generateMetadata(), preventing the error boundary from being triggered.

Fix

Separate layout modules from the page module when resolving metadata/viewport in buildPageElement():

  • Layouts: .catch(() => null) — failures are non-fatal
  • Page: no .catch() — errors propagate to the caller, which routes to error.tsx / global-error.tsx

Test

The previously failing test now passes:

tests/nextjs-compat/global-error.test.ts
  > generateMetadata() error caught by local error.tsx boundary  ✓

When parallelising metadata resolution, layout errors should be
swallowed (.catch(() => null)) but page-level generateMetadata()
errors must propagate so the caller can route them to the nearest
error.tsx or global-error.tsx boundary.

Fixes the regression introduced by the parallelisation PR where
a throwing generateMetadata() on the page module was silently
swallowed instead of triggering the error boundary.
@james-elicx james-elicx marked this pull request as draft March 9, 2026 11:03
@james-elicx james-elicx merged commit 2b3d082 into j-branch-11 Mar 9, 2026
@james-elicx james-elicx deleted the fix/metadata-error-propagation branch March 9, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant