vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.4k stars 27.03k forks source link

Intercepted routes don't update metadata #72938

Open pseudotsuga-fir opened 1 week ago

pseudotsuga-fir commented 1 week ago

Link to the code that reproduces this issue

https://github.com/pseudotsuga-fir/nextgram-broken-metadata

To Reproduce

  1. Add unique metadata to an intercepted route

    export async function generateMetadata({
    params,
    }: {
    params: Promise<{ id: string }>;
    }): Promise<Metadata> {
    const id = (await params).id;
    
    return {
    title: `Page ${id} intercepted`,
    };
    }
  2. Add link to a page that leads to intercepted route, see that intercepted page does not change the metadata

Current vs. Expected behavior

Current

Metadata remains the same as the current page when intercepting a route, despite the intercepted route providing its own metadata. The metadata for the intercepted route WILL display however under the specific circumstance of navigating as such via the <Link> component: Page 1 (provides custom metadata) > Page 2 (does not provide metadata) > Intercepted Route (provides custom metadata).

Screenshot 2024-11-18 at 2 49 26 PM

Expected

Metadata updates upon navigating to an intercepted route based on the metadata provided in the page of that route.

Screenshot 2024-11-18 at 2 49 58 PM

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 22.2.0: Fri Nov 11 02:06:26 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8112
  Available memory (MB): 24576
  Available CPU cores: 8
Binaries:
  Node: 20.18.0
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: 8.9.0
Relevant Packages:
  next: 15.0.3 // Latest available version is detected (15.0.3).
  eslint-config-next: N/A
  react: 19.0.0-rc-fb9a90fa48-20240614
  react-dom: 19.0.0-rc-fb9a90fa48-20240614
  typescript: 5.6.3
Next.js Config:
  output: N/A

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

Metadata, Parallel & Intercepting Routes

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

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

Additional context

Working example: Repo and Live

This bug was fixed in v14.0.5-canary.24, likely by one of these two pull requests:

The last working version was v14.1.4; I was unable to find which canary version or commits broke this. Issue has remained present since.

Does not work in current canary version as of writing this issue: v15.0.4-canary.18

samcx commented 1 week ago

@pseudotsuga-fir I was able to replicate this! We are taking a look :one-eye-cowboy: