cb24c555a6
### What This PR changes the flow of not-found rendering process. ### Why `not-found.js` was rendered in two ways before: * 1 is SSR rendering the not-found as 404 * 2 is triggering the error on RSC rendering then the error will be preserved in inline flight data, on the client it will recover the error and trigger the proper error boundary. The solution has been through a jounery: No top-level not found boundary -> introduce metadata API -> then we create a top level root not found boundary -> then we delete it due to duplicated rendering of root layout -> now this So the solution before this PR is still having a root not found boundary wrapped in the `AppRouter`, it's being used in a lot of places including HMR. As we discovered it's doing duplicated rendering of root layout, then we removed it and it started failing with rendering `not-found` but missing root layout. In this PR we redesign the process. ### How Now the rendering architecture looks like: * For normal root not-found and certain level of not-found boundary they're still covered by `LayoutRouter` * For other error renderings including not-found * Fully remove the top level not-found boundary, when it renders with 404 error it goes to render the fallback page * During rendering the fallback page it will check if it should just renders a 404 error page or render nothing and let the error from inline flight data to trigger the error boundary pseudo code ``` try { render AppRouter > PageComponent } catch (err) { create ErrorComponent by determine err render AppRouter > ErrorComponent } ``` In this way if the error is thrown from top-level like the page itself or even from metadata, we can still catch them and render the proper error page based on the error type. The problematic is the HMR: introduces a new development mode meta tag `<meta name="next-error">` to indicate it's 404 so that we don't do refresh. This reverts the change brougt in #51637 as it will also has the duplicated rendering problem for root layout if it's included in the top level not found boundary. Also fixes the root layout missing issue: Fixes #52718 Fixes #52739 --------- Co-authored-by: Shu Ding <g@shud.in> |
||
---|---|---|
.cargo | ||
.config | ||
.devcontainer | ||
.github | ||
.husky | ||
.vscode | ||
bench | ||
contributing | ||
docs | ||
errors | ||
examples | ||
packages | ||
scripts | ||
test | ||
.alexignore | ||
.alexrc | ||
.eslintignore | ||
.eslintrc.json | ||
.gitattributes | ||
.gitignore | ||
.npmrc | ||
.prettierignore | ||
.prettierignore_staged | ||
.prettierrc.json | ||
.rustfmt.toml | ||
azure-pipelines.yml | ||
Cargo.lock | ||
Cargo.toml | ||
CODE_OF_CONDUCT.md | ||
contributing.md | ||
jest.config.js | ||
jest.replay.config.js | ||
lerna.json | ||
license.md | ||
lint-staged.config.js | ||
package.json | ||
plopfile.js | ||
pnpm-lock.yaml | ||
pnpm-workspace.yaml | ||
readme.md | ||
release.js | ||
run-tests.js | ||
rust-toolchain | ||
test-file.txt | ||
tsconfig-tsec.json | ||
tsconfig.json | ||
tsec-exemptions.json | ||
turbo.json | ||
UPGRADING.md | ||
vercel.json |
Next.js
Getting Started
Visit https://nextjs.org/learn to get started with Next.js.
Documentation
Visit https://nextjs.org/docs to view the full documentation.
Who is using Next.js?
Next.js is used by the world's leading companies. Check out the Next.js Showcase to learn more.
Community
The Next.js community can be found on GitHub Discussions, where you can ask questions, voice ideas, and share your projects.
To chat with other community members you can join the Next.js Discord.
Our Code of Conduct applies to all Next.js community channels.
Contributing
Please see our contributing.md.
Good First Issues
We have a list of good first issues that contain bugs that have a relatively limited scope. This is a great place to get started, gain experience, and get familiar with our contribution process.
Authors
- Tim Neutkens (@timneutkens)
- Naoyuki Kanezawa (@nkzawa)
- Guillermo Rauch (@rauchg)
- Arunoda Susiripala (@arunoda)
- Tony Kovanen (@tonykovanen)
- Dan Zajdband (@impronunciable)
Security
If you believe you have found a security vulnerability in Next.js, we encourage you to responsibly disclose this and not open a public issue. We will investigate all legitimate reports. Email security@vercel.com
to disclose any security vulnerabilities.