-
Notifications
You must be signed in to change notification settings - Fork 27k
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 unhandled runtime error from generateMetadata in parallel routes #72153
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…data w/ parallel routes (#65102) When a page throws a `notFound()` error in `generateMetadata`, and the page contains parallel route(s), an unhandled runtime error would be thrown rather than displaying the not found page. We use the `<MetadataOutlet />` component to throw any errors caught during metadata resolution once the metadata is rendered by React so that it can be caught by an error boundary, so that it doesn't throw during metadata resolution. A promise is tracked & resolved with an error once the metadata tree is rendered. Once the promise resolves, the outlet component will throw. However, every `__PAGE__` segment that would be rendered as part of the page the user is on will render this `<MetadataOutlet />` component. We only need a single outlet per segment as only a single error needs to be thrown & caught. This will only render a `MetadataOutlet` for the first parallel route that is encountered at each segment depth, as we only need a single handler to throw the error. Fixes #65013 Closes NEXT-3222
Tests Passed |
huozhi
changed the title
fix unhandled runtime error when notFound() triggered in generateMeta…
fix unhandled runtime error from generateMetadata in parallel routes
Oct 31, 2024
Stats from current PRDefault Build (Increase detected
|
vercel/next.js 14-2-1 | vercel/next.js fix/metadata-parallel-route | Change | |
---|---|---|---|
buildDuration | 19.7s | 18.2s | N/A |
buildDurationCached | 9.4s | 8.1s | N/A |
nodeModulesSize | 200 MB | 200 MB | |
nextStartRea..uration (ms) | 465ms | 445ms | N/A |
Client Bundles (main, webpack)
vercel/next.js 14-2-1 | vercel/next.js fix/metadata-parallel-route | Change | |
---|---|---|---|
1a9f679d-HASH.js gzip | 53.7 kB | 53.7 kB | N/A |
5428.HASH.js gzip | 181 B | 180 B | N/A |
6067-HASH.js gzip | 5.06 kB | 5.06 kB | N/A |
6428-HASH.js gzip | 31.6 kB | 31.6 kB | N/A |
framework-HASH.js gzip | 44.9 kB | 44.9 kB | ✓ |
main-app-HASH.js gzip | 242 B | 242 B | ✓ |
main-HASH.js gzip | 32.3 kB | 32.3 kB | N/A |
webpack-HASH.js gzip | 1.68 kB | 1.68 kB | N/A |
Overall change | 45.1 kB | 45.1 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js 14-2-1 | vercel/next.js fix/metadata-parallel-route | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 39.4 kB | 39.4 kB | ✓ |
Overall change | 39.4 kB | 39.4 kB | ✓ |
Client Pages
vercel/next.js 14-2-1 | vercel/next.js fix/metadata-parallel-route | Change | |
---|---|---|---|
_app-HASH.js gzip | 196 B | 196 B | ✓ |
_error-HASH.js gzip | 184 B | 185 B | N/A |
amp-HASH.js gzip | 502 B | 504 B | N/A |
css-HASH.js gzip | 321 B | 324 B | N/A |
dynamic-HASH.js gzip | 1.82 kB | 1.82 kB | N/A |
edge-ssr-HASH.js gzip | 258 B | 257 B | N/A |
head-HASH.js gzip | 352 B | 352 B | ✓ |
hooks-HASH.js gzip | 371 B | 372 B | N/A |
image-HASH.js gzip | 4.23 kB | 4.23 kB | N/A |
index-HASH.js gzip | 259 B | 257 B | N/A |
link-HASH.js gzip | 2.67 kB | 2.68 kB | N/A |
routerDirect..HASH.js gzip | 316 B | 314 B | N/A |
script-HASH.js gzip | 385 B | 386 B | N/A |
withRouter-HASH.js gzip | 311 B | 310 B | N/A |
1afbb74e6ecf..834.css gzip | 106 B | 106 B | ✓ |
Overall change | 654 B | 654 B | ✓ |
Client Build Manifests
vercel/next.js 14-2-1 | vercel/next.js fix/metadata-parallel-route | Change | |
---|---|---|---|
_buildManifest.js gzip | 483 B | 481 B | N/A |
Overall change | 0 B | 0 B | ✓ |
Rendered Page Sizes
vercel/next.js 14-2-1 | vercel/next.js fix/metadata-parallel-route | Change | |
---|---|---|---|
index.html gzip | 529 B | 527 B | N/A |
link.html gzip | 542 B | 539 B | N/A |
withRouter.html gzip | 525 B | 522 B | N/A |
Overall change | 0 B | 0 B | ✓ |
Edge SSR bundle Size
vercel/next.js 14-2-1 | vercel/next.js fix/metadata-parallel-route | Change | |
---|---|---|---|
edge-ssr.js gzip | 95.5 kB | 95.5 kB | N/A |
page.js gzip | 3.06 kB | 3.06 kB | N/A |
Overall change | 0 B | 0 B | ✓ |
Middleware size
vercel/next.js 14-2-1 | vercel/next.js fix/metadata-parallel-route | Change | |
---|---|---|---|
middleware-b..fest.js gzip | 656 B | 657 B | N/A |
middleware-r..fest.js gzip | 156 B | 154 B | N/A |
middleware.js gzip | 25.5 kB | 25.5 kB | N/A |
edge-runtime..pack.js gzip | 839 B | 839 B | ✓ |
Overall change | 839 B | 839 B | ✓ |
Next Runtimes
vercel/next.js 14-2-1 | vercel/next.js fix/metadata-parallel-route | Change | |
---|---|---|---|
app-page-exp...dev.js gzip | 171 kB | 171 kB | N/A |
app-page-exp..prod.js gzip | 98.3 kB | 98.3 kB | N/A |
app-page-tur..prod.js gzip | 100 kB | 100 kB | N/A |
app-page-tur..prod.js gzip | 94.3 kB | 94.3 kB | N/A |
app-page.run...dev.js gzip | 145 kB | 145 kB | N/A |
app-page.run..prod.js gzip | 92.8 kB | 92.8 kB | N/A |
app-route-ex...dev.js gzip | 22.1 kB | 22.1 kB | ✓ |
app-route-ex..prod.js gzip | 15.5 kB | 15.5 kB | ✓ |
app-route-tu..prod.js gzip | 15.5 kB | 15.5 kB | ✓ |
app-route-tu..prod.js gzip | 15.2 kB | 15.2 kB | ✓ |
app-route.ru...dev.js gzip | 21.7 kB | 21.7 kB | ✓ |
app-route.ru..prod.js gzip | 15.2 kB | 15.2 kB | ✓ |
pages-api-tu..prod.js gzip | 9.58 kB | 9.58 kB | ✓ |
pages-api.ru...dev.js gzip | 9.85 kB | 9.85 kB | ✓ |
pages-api.ru..prod.js gzip | 9.57 kB | 9.57 kB | ✓ |
pages-turbo...prod.js gzip | 22.5 kB | 22.5 kB | ✓ |
pages.runtim...dev.js gzip | 23.2 kB | 23.2 kB | ✓ |
pages.runtim..prod.js gzip | 22.5 kB | 22.5 kB | ✓ |
server.runti..prod.js gzip | 51.6 kB | 51.6 kB | ✓ |
Overall change | 254 kB | 254 kB | ✓ |
build cache Overall increase ⚠️
vercel/next.js 14-2-1 | vercel/next.js fix/metadata-parallel-route | Change | |
---|---|---|---|
0.pack gzip | 1.6 MB | 1.6 MB | |
index.pack gzip | 113 kB | 113 kB | N/A |
Overall change | 1.6 MB | 1.6 MB |
Diff details
Diff for middleware.js
Diff too large to display
Diff for edge-ssr.js
Diff too large to display
Diff for app-page-exp..ntime.dev.js
Diff too large to display
Diff for app-page-exp..time.prod.js
Diff too large to display
Diff for app-page-tur..time.prod.js
Diff too large to display
Diff for app-page-tur..time.prod.js
Diff too large to display
Diff for app-page.runtime.dev.js
Diff too large to display
Diff for app-page.runtime.prod.js
Diff too large to display
ijjk
approved these changes
Oct 31, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Backport #65102, #65343 (as they are fixing the same issue)
x-ref: slack