Inconsistent revalidate behavior when deployed to Vercel
Link to the code that reproduces this issue
https://github.com/Darkness-2/nextjs-revalidate-bug
To Reproduce
- Deploy app to Vercel
- Invoke revalidatePath for a path with a short revalidate interval (for example, 60 seconds)
- Note the expected behavior is that the next visit to this page will receive a
X-Vercel-Cache: REVALIDATEDheader - However, on occasion you will receive an unexpected
X-Vercel-Cache: HITorX-Vercel-Cache: STALE, and stale data will be served - No matter how many more times the page is hit, the cache does not seem to revalidate until the end of the next revalidate interval
Please note, this does not seem to happen every time, however if you play around with it enough, you will find this behavior. My experience is that this tends to happen very close to when the page is around its revalidation interval (a few seconds before or after the 60 second revalidation period).
I have also tested this locally using npm run build and npm run start, and it works as expected. (Note that when running locally the relevant header is X-Nextjs-Cache)
Note below a reproduction, where I called revalidatePath via a route handler, and the subsequent request for the page's rsc still returned a X-Vercel-Cache: HIT
Current vs. Expected behavior
Following the steps from the previous section, I expect the next request after a revalidatePath to return a X-Vercel-Cache: REVALIDATED header, along with fresh data.
Instead, a X-Vercel-Cache: HIT or X-Vercel-Cache: STALE header is sometimes returned, along with stale data. The page does not appear to ever be revalidated in these cases, even though revalidatePath was invoked.
Verify canary release
- [X] I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Home
Binaries:
Node: 18.18.2
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 14.0.3
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
typescript: 5.3.2
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
App Router
Additional context
I have created an example repo, along with Vercel deployment where it is easy to reproduce the issue, along with instructions for what to look out for.
I also deployed the same project on the canary release to Vercel, and the same issue occurred.
This is really a BIG BIG issue, I'm very scare to publish our app for client to use...
This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.
This issue has been automatically closed due to two years of inactivity. If you’re still experiencing a similar problem or have additional details to share, please open a new issue following our current issue template. Your updated report helps us investigate and address concerns more efficiently. Thank you for your understanding!
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.