Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hallatore/revalidate-bug
https://github.com/hallatore/revalidate-bug
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/hallatore/revalidate-bug
- Owner: hallatore
- Created: 2023-11-25T18:20:09.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-25T20:06:20.000Z (about 1 year ago)
- Last Synced: 2024-10-29T18:37:34.604Z (3 months ago)
- Language: TypeScript
- Size: 48.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
NEXT revalidate bug
The following code features a static page with a fetch call set to revalidate every 5 seconds. This causes the page to also revalidate every 5 seconds, as expected.
But when the page revalidates the fetch-call returns a stale response and revaldate itself, causing a revalidate chain that doubles the time it takes to refresh data, and causes extra calls.
```
async function Page() {
const response = await fetch(
"http://worldtimeapi.org/api/timezone/Europe/Oslo",
{
next: {
revalidate: 5,
},
}
);const json = (await response.json()) as { datetime: string };
// Note: function is run twice for some reason. This is a different bug: https://github.com/vercel/next.js/issues/58736
console.log("datetime", json.datetime);return (
Time should update every 5 seconds. Not every 10.
{json.datetime}
);
}export default Page;
```## Diagram showing what happens
![image](https://github.com/hallatore/revalidate-bug/assets/365605/22d189fe-07da-47df-8b4e-f90b2d8d2ab0)