Skip to content
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

notFound() thrown in dynamic segment shows "pages" 404 while app/not-found.tsx is present #54174

Closed
1 task done
MKraust opened this issue Aug 17, 2023 · 2 comments · Fixed by #54185
Closed
1 task done
Assignees
Labels
locked Navigation Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@MKraust
Copy link

MKraust commented Aug 17, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.4.0: Mon Mar  6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000
    Binaries:
      Node: 18.16.1
      npm: 9.5.1
      Yarn: N/A
      pnpm: 8.3.1
    Relevant Packages:
      next: 13.4.17
      eslint-config-next: 13.4.17
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

App Router, Routing (next/router, next/navigation, next/link)

Link to the code that reproduces this issue or a replay of the bug

https://github.com/MKraust/next-404-segment-bug

To Reproduce

  1. Run npm run build && npm run start
  2. Go to /dynamic/404
  3. See that "pages" 404 is rendered inside app/dynamic/layout.tsx instead of app/not-found.tsx
  4. Go to /foo/bar
  5. See that app/not-found.tsx is rendered correctly
  6. Go to /dynamic-with-not-found/404
  7. See that app/dynamic-with-not-found/[slug]/not-found.tsx is rendered correctly (same if move app/dynamic-with-not-found/[slug]/not-found.tsx to app/dynamic-with-not-found/not-found.tsx)

Describe the Bug

notFound() thrown in dynamic segment shows "pages" 404 while root app/not-found.tsx is present.

Expected Behavior

I expect that notFound() thrown anywhere would propagate to the first matching not-found.tsx in the app/ hierarchy.
In case of /dynamic/404 it's root app/not-found.tsx. It's working properly on next@13.4.12

That behavior is described here. Specifically, the words:

Good to know: In addition to catching expected notFound() errors, the root app/not-found.js file also handles any unmatched URLs for your whole application.

Which browser are you using? (if relevant)

115.0.5790.170 (arm64)

How are you deploying your application? (if relevant)

next start

@MKraust MKraust added the bug Issue was opened via the bug report template. label Aug 17, 2023
@github-actions github-actions bot added the Navigation Related to Next.js linking (e.g., <Link>) and navigation. label Aug 17, 2023
@MKraust
Copy link
Author

MKraust commented Aug 17, 2023

Could be related to #53703, #54080 and #54051 (specifically, "pages" 404 still used if app/not-found.tsx is present).

@huozhi huozhi added kind: bug and removed bug Issue was opened via the bug report template. labels Aug 17, 2023
@huozhi huozhi self-assigned this Aug 17, 2023
@kodiakhq kodiakhq bot closed this as completed in #54185 Aug 17, 2023
kodiakhq bot pushed a commit that referenced this issue Aug 17, 2023
…for root layer only (#54185)

Fixes #54174 

We should only add default not-found boundary to loader tree components for root layout. It was accidently added for children routes before
@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2023

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot added the locked label Sep 1, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
2 participants