revalidatePath in server actions broken?
Unanswered
Scarlet Ibis posted this in #help-forum
Scarlet IbisOP
I have a server component page that provides a listing from a DB call. On this page there is a client component that contains a form to submit a new item for the listing via a server action. If I dont use revalidate, then the listing doesn't refresh unless i reload the page. If I revalidate the path, then the listing will refresh without a reload.
I inadvertently made a typo in my path, but the listing still refreshed. I tried various other non-correct paths, and on each occasion the listing would refresh. I removed the call to revalidatePath and the listing no longer refreshed.
It seems to me that this is broken behaviour. Why would specifying ANY path to revalidatePath cause my target path to be revalidated? Am I misunderstanding how this is supposed to work?
I inadvertently made a typo in my path, but the listing still refreshed. I tried various other non-correct paths, and on each occasion the listing would refresh. I removed the call to revalidatePath and the listing no longer refreshed.
It seems to me that this is broken behaviour. Why would specifying ANY path to revalidatePath cause my target path to be revalidated? Am I misunderstanding how this is supposed to work?
2 Replies
Scarlet IbisOP
OK - i went back and read the documentation at https://nextjs.org/docs/app/api-reference/functions/revalidatePath
and it states under "good to know":
So i guess that explains that.
and it states under "good to know":
Currently, revalidatePath invalidates all the routes in the client-side Router Cache. This behavior is temporary and will be updated in the future to apply only to the specific path.So i guess that explains that.
West African Crocodile
I guess I ran into the same issue: https://nextjs-forum.com/post/1230456998462623856#message-1230456998462623856
So I guess we should keep in mind that this will be changed in the future, so we will need to revalidate multiple paths if needed, so in my cae /posts and /posts/[postId]
So I guess we should keep in mind that this will be changed in the future, so we will need to revalidate multiple paths if needed, so in my cae /posts and /posts/[postId]