I'm trying to using revalidateTag
Answered
Raspberry Horntail posted this in #help-forum
Raspberry HorntailOP
I'm trying to cache a lambda result like this, but when I try to revalidateTag it, it throw the following error: Invariant: static generation store missing in revalidateTag
Answered by Savannah
RevalidateTags seems inconsistent. I use how i personally am using it and getting it to work.
page.jsx:
serveractions.js:
page.jsx:
"use server"
import handleNewFolder from "serveractions.js"
async function fetchFolders() {
//just a helper function with regular fetch you don't need a custom fetch function
return await fetchWithCookies(`/api/folders`, "GET", {
next: { tags: ["Folders"] },
});
}
<form action={handleNewFolder}>serveractions.js:
"use server"
export async function handleNewFolder(formData) {
const responseData = await fetchWithCookies("/api/folders", "POST", {
body: JSON.stringify(newFolder),
headers: { "Content-Type": "application/json" }
});
revalidateTag("Folders");13 Replies
@Raspberry Horntail I'm trying to cache a lambda result like this, but when I try to revalidateTag it, it throw the following error: Invariant: static generation store missing in revalidateTag
Savannah
Alright so i have a descent amount of experience with this now, but there are some use cases i get this error with still, but i'll try to help. is dynamicprops a server component?
and what is calling inventory-revalidate
is it a form?
Raspberry HorntailOP
I'm making it a server component
it's just a API
@Raspberry Horntail it's just a API
Savannah
Are you looking for on demand without refreshing a page revalidation? or just when someone refreshes the data is changed?
Also is unstable_cache calling fetch? with next tags? The proper way to tag is
next: { tags: ["Chats"] },@Savannah Are you looking for on demand without refreshing a page revalidation? or just when someone refreshes the data is changed?
Raspberry HorntailOP
I would like, in principle, to start with "on demand" revalidation. When my "headless cms" changes some date, I need some pages to be invalidated, it would be nice if all of them were invalidated by the Tag. That's what I'm trying to test.
@Savannah Also is unstable_cache calling fetch? with next tags? The proper way to tag is next: { tags: ["Chats"] },
Raspberry HorntailOP
I'm trying to follow the example of VERCEL's platforms project. https://github.com/vercel/platforms/blob/main/lib/fetchers.ts
Savannah
Ah i had no idea you could call tags on objects outside of fetch. This is outside my knowledge sorry
Raspberry HorntailOP
No problem, but anyway, if I make my lambda request accessible via fetch, probably the tags would work, according to the docs, right? I think that's what to start testing. Thanks for the help so far. If I'm successful, I'll let you know
@Raspberry Horntail No problem, but anyway, if I make my lambda request accessible via fetch, probably the tags would work, according to the docs, right? I think that's what to start testing. Thanks for the help so far. If I'm successful, I'll let you know
Savannah
RevalidateTags seems inconsistent. I use how i personally am using it and getting it to work.
page.jsx:
serveractions.js:
page.jsx:
"use server"
import handleNewFolder from "serveractions.js"
async function fetchFolders() {
//just a helper function with regular fetch you don't need a custom fetch function
return await fetchWithCookies(`/api/folders`, "GET", {
next: { tags: ["Folders"] },
});
}
<form action={handleNewFolder}>serveractions.js:
"use server"
export async function handleNewFolder(formData) {
const responseData = await fetchWithCookies("/api/folders", "POST", {
body: JSON.stringify(newFolder),
headers: { "Content-Type": "application/json" }
});
revalidateTag("Folders");Answer
Savannah
Not my full code, but enough to under stand. I found calling revalidateTag inside a route directly would cause issues with invariant errors