-
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
not-found loses layout #52718
Comments
To contrast this with the previous behavior, I forked the sandbox above to downgrade to CodeSandbox: https://codesandbox.io/p/sandbox/immutable-thunder-ym59x5?file=%2Fapp%2Fnot-found.tsx%3A1%2C1 Kapture.2023-07-14.at.16.48.53.mp4 |
Potential duplicate issue here: |
### 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 <[email protected]>
Thanks for #52790 @huozhi and @ijjk 🙌 However, I noticed that PR was reverted in #52977 before the release of Should we reopen this issue until it's landed permanently? |
I'm not sure if this is related, but the not-found.js file is being resolved to a parent route when set under a dynamic route. E.g. In the following tree, under the route /bovines/[id], the
|
Reland #52790 Reverts #52977 was failed due to failed job [vercel/next.js/actions/runs/5616458194/job/15220295829](https://github.com/vercel/next.js/actions/runs/5616458194/job/15220295829) Should be fine to resolve with #52979 now Fixes #52718 Fixes #52739 --------- Co-authored-by: Alex Kirszenberg <[email protected]> Co-authored-by: Tobias Koppers <[email protected]>
Thanks for the re-land in #52985 @huozhi @ijjk 🙌 I can confirm that it's working - the layout is back for CodeSandbox: https://codesandbox.io/p/sandbox/determined-bash-hp979v?file=%2Fpackage.json%3A10%2C24 Kapture.2023-07-24.at.11.13.29.mp4 |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #22 SMP Tue Jan 10 18:39:00 UTC 2023 Binaries: Node: 16.17.0 npm: 8.15.0 Yarn: 1.22.19 pnpm: 7.1.0 Relevant Packages: next: 13.4.10-canary.8 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 4.9.5 Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
App Router
Link to the code that reproduces this issue or a replay of the bug
https://codesandbox.io/p/sandbox/sleepy-leavitt-q76g5v?file=%2Fapp%2Fnot-found.tsx
To Reproduce
Kapture.2023-07-14.at.16.42.03.mp4
Describe the Bug
The not-found page no longer receives a layout
Expected Behavior
The not-found page receives a layout
Related issues / PRs
Possibly related to this issue and the PR addressing it:
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
NEXT-1449
The text was updated successfully, but these errors were encountered: