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() wrong Metadata after hydration #68392

Closed
valeryq opened this issue Aug 1, 2024 · 4 comments
Closed

notFound() wrong Metadata after hydration #68392

valeryq opened this issue Aug 1, 2024 · 4 comments
Labels
bug Issue was opened via the bug report template. locked Metadata Related to Next.js' Metadata API.

Comments

@valeryq
Copy link

valeryq commented Aug 1, 2024

Link to the code that reproduces this issue

https://github.com/valeryq/nextjs-not-found-metadata-bug-debug

To Reproduce

There are 2 behaviors:

  1. Route does not exist at all in the application (work as expected).
    URL: https://nextjs-not-found-metadata-bug-debug.vercel.app/

image

  1. Route /test with notFound() in Server Component render function (doesn't work as expected, wrong metadata).
    URL: https://nextjs-not-found-metadata-bug-debug-p93w1k52u.vercel.app/test

P.S. The metadata does not exist at all in not-found.tsx. If there is some metadata in layout.tsx, it will apply, but not the metadata from not-found.tsx. Although the server-rendered HTML returned from the server contains the title, after hydration it seems like something overrides it, because I can see a brief flash of the 404 | Not found title, and then it disappears.
image
image

Current vs. Expected behavior

Current:
Metadata from not-found.tsx isn't applied when notFound() function is invoked manually.

Expected:
Metadata is applied from not-found.tsx when notFound() function is invoked manually.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 20.12.0
  npm: 10.5.0
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 14.2.5 // Latest available version is detected (14.2.5).
  eslint-config-next: 14.2.5
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.5.4
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Metadata

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local), Vercel (Deployed), Other (Deployed)

Additional context

The result is the same whether I use local dev server, built version, deployed on Vercel or custom build on k8s cluster in docker container.

@valeryq valeryq added the bug Issue was opened via the bug report template. label Aug 1, 2024
@github-actions github-actions bot added the Metadata Related to Next.js' Metadata API. label Aug 1, 2024
@jrjake
Copy link

jrjake commented Aug 3, 2024

I think this might be a duplicate of #45620, this person has a workaround for specifically calling notFound() in a page: #45620 (comment)

@valeryq
Copy link
Author

valeryq commented Aug 5, 2024

@jrjake It looks like invoking notFound() fn in my dynamic page in generateMetadata gives no positive effect and even worse, I received nothing even from parent generateMetadata.

@samcx
Copy link
Member

samcx commented Aug 8, 2024

@valeryq Thank you for submitting an issue!

Can confirm this is still an issue. I will close this one in favor of the original.

@samcx samcx closed this as completed Aug 8, 2024
Copy link
Contributor

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 locked as resolved and limited conversation to collaborators Aug 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked Metadata Related to Next.js' Metadata API.
Projects
None yet
Development

No branches or pull requests

3 participants