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
Triggering notFound in generateMetadata results in Unhandled Runtime Error Error: NEXT_NOT_FOUND #65013
Labels
bug
Issue was opened via the bug report template.
Parallel & Intercepting Routes
Related to Parallel and/or Intercepting routes.
Comments
github-actions
bot
added
the
Parallel & Intercepting Routes
Related to Parallel and/or Intercepting routes.
label
Apr 25, 2024
ztanner
added a commit
that referenced
this issue
Apr 29, 2024
…data w/ parallel routes (#65102) ### What 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. ### Why 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. ### How 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Issue was opened via the bug report template.
Parallel & Intercepting Routes
Related to Parallel and/or Intercepting routes.
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/falling-water-nky943
To Reproduce
generateMetadata
for example/en/test
_
to@articleModal
fixes the issue as the parallel route doesn't exit any more.Current vs. Expected behavior
I expected to see a not found page but got an unhandled runtime error with the thrown "NEXT_NOT_FOUND_ error.
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:34 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T8103 Available memory (MB): 16384 Available CPU cores: 8 Binaries: Node: 20.11.1 npm: 10.2.4 Yarn: N/A pnpm: N/A Relevant Packages: next: 14.3.0-canary.22 // Latest available version is detected (14.3.0-canary.22). eslint-config-next: 14.1.4 react: 18.2.0 react-dom: 18.2.0 typescript: 5.4.2 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Parallel & Intercepting Routes
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local)
Additional context
Triggering notFound in generateMetadata results in
Unhandled Runtime Error Error: NEXT_NOT_FOUND
The text was updated successfully, but these errors were encountered: