You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
=== Will redirect ===
--- Rendering ---
--- Fetching data ---
--- Generating metadata ---
--- Generating metadata ---
--- Fetching data ---
Metadata is called twice. Second time is not during the same server request and cache is not working
Current vs. Expected behavior
There is intentionally a timeout in fetch data. During these 2 seconds monitor network responses. While waiting for the page to load, the type changes from document to document / Redirect. This is when metadata is being changed by permanentRedirect and is causing the second call of generateMetadata.
Expecting to either not call generateMetadata twice or have an indicator to understand that it is the second request and not call fetch data
This has a high impact in our servers as we are not doing a single cached fetched
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.4.0: Fri Apr 11 18:32:50 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6041
Available memory (MB): 24576
Available CPU cores: 12
Binaries:
Node: 20.11.1
npm: 10.2.4
Yarn: 1.22.22
pnpm: 10.9.0
Relevant Packages:
next: 15.2.3 // There is a newer version (15.3.2) available, upgrade recommended!
eslint-config-next: N/A
react: 19.1.0
react-dom: 19.1.0
typescript: 5.8.3
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 start (local)
Additional context
I tested it also in the latest version and it happening there too
The text was updated successfully, but these errors were encountered:
It's expected that generateMetadata is called twice here, because the server receives two requests (one for the even number, and the other for the odd number param after the redirect roundtrip).
Link to the code that reproduces this issue
https://github.com/mcAnastasiou/nextjs-memoization-issue
To Reproduce
Should see
Should see
Metadata is called twice. Second time is not during the same server request and cache is not working
Current vs. Expected behavior
There is intentionally a timeout in fetch data. During these 2 seconds monitor network responses. While waiting for the page to load, the type changes from
document
todocument / Redirect
. This is when metadata is being changed by permanentRedirect and is causing the second call of generateMetadata.Expecting to either not call generateMetadata twice or have an indicator to understand that it is the second request and not call fetch data
This has a high impact in our servers as we are not doing a single cached fetched
Provide environment information
Which area(s) are affected? (Select all that apply)
Metadata
Which stage(s) are affected? (Select all that apply)
next start (local)
Additional context
I tested it also in the latest version and it happening there too
The text was updated successfully, but these errors were encountered: