Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/blissful-alex-456x8x?layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clyg9bptg00063j6kfzrtt3fc%2522%252C%2522sizes%2522%253A%255B70.12953367875647%252C29.870466321243526%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clyg9bptg00023j6k3w4rphuo%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clyg9bptg00043j6kmh0go18l%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clyg9bptg00053j6kuo9qzs1s%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clyg9bptg00023j6k3w4rphuo%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clyg9bptg00013j6kpjw6zalf%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252FREADME.md%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%252C%2522id%2522%253A%2522clyg9bptg00023j6k3w4rphuo%2522%252C%2522activeTabId%2522%253A%2522clyg9bptg00013j6kpjw6zalf%2522%257D%252C%2522clyg9bptg00053j6kuo9qzs1s%2522%253A%257B%2522id%2522%253A%2522clyg9bptg00053j6kuo9qzs1s%2522%252C%2522activeTabId%2522%253A%2522clylmf4wx00db3j6kdqtpusu6%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A3000%252C%2522id%2522%253A%2522clylmf4wx00db3j6kdqtpusu6%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522path%2522%253A%2522%252Fcached%252F24h%2522%257D%255D%257D%252C%2522clyg9bptg00043j6kmh0go18l%2522%253A%257B%2522id%2522%253A%2522clyg9bptg00043j6kmh0go18l%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522pnpm%2520run%2520start%2522%252C%2522id%2522%253A%2522clylnrz7h00xc3j6kvp3ugs6o%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%255D%252C%2522activeTabId%2522%253A%2522clylnrz7h00xc3j6kvp3ugs6o%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D
To Reproduce
- Build the app with
pnpm run build
- Start the app with
pnpm run start
- Visit page
/cached/24h, write down the timestamp shown on the page
- Wait for 24 hours (or manually age the cache on FS with `touch -d “-24 hour” “path/to/multiple/cached/files/of/the/corresponding/route” – I have tried both)
- Visit page
/cached/24h again, optionally refresh as many times as you like, observe the console output and the actual rendered content
Current vs. Expected behavior
Current Behavior
- The rendered content page
/cached/24h remains stale, despite that:
- The console shows that the component is re-rendered after the reproducing step 5 (I have added a
console.log to determine if it is re-rendered);
- The console shows that the fetching function wrapped by
unstable_cache was executed after the reproducing step 5 (I have added a console.log inside the fetch function to determine if it is executed);
- The “Modify” and “Change” timestamps of the cache files are updated, but their contents are stale.
- The “control group” page
/cached/10s is revalidating and persisting the cache correctly.
The current behavior means that when the page /cached/24h is revalidated, although the fetch function wrapped by unstable_cache is executed again, its latest result is overwritten by stale result no matter what. The “control group” page /cached/10s, however, works fine, meaning that this issue is related to specific revalidation interval(s).
Expected Behavior
The page /cached/24h is revalidated and cached correctly, such that when visited (and refreshed) 24h later, it shows a timestamp within approximately 24h.
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023
Available memory (MB): 4102
Available CPU cores: 2
Binaries:
Node: 20.9.0
npm: 9.8.1
Yarn: 1.22.19
pnpm: 8.10.2
Relevant Packages:
next: 15.0.0-canary.66 // Latest available version is detected (15.0.0-canary.66).
eslint-config-next: N/A
react: 19.0.0-rc-6f23540c7d-20240528
react-dom: 19.0.0-rc-6f23540c7d-20240528
typescript: 5.3.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Output (export/standalone)
Which stage(s) are affected? (Select all that apply)
next start (local), Vercel (Deployed)
Additional context
The same happens in Next 15 RC version:
The same problem exists in Next 13.5.4. Interestingly, Next 15 RC and Canary seem to NOT have this issue if the route is dynamic (e.g., /cached/[interval]), while in Next 13.5.4, the same issue happens to dynamic routes.
Same. For now, I’m forced to manually
revalidateTag/revalidatePath.