-
Notifications
You must be signed in to change notification settings - Fork 26.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
revalidatePath in server action is not revalidating the path(s) #50356
Comments
To benefit from the path revalidation, I believe you have to use a regular function and not an arrow function for your server actions.
|
Even after changing to a regular function, the page(s) still will not revalidate. |
|
I just figured out my issue with revalidate path using MongoDB, it was rather silly but perhaps it may help you
Database action
my mistake was that I forgot to await my So, I'm guessing perhaps revalidatePath("/") is being triggered before awaiting for |
@latinrev In the repo I shared above I'm awaiting on line 10 I think the problem is different because it seems like revalidatePath is revalidating the path it's currently on rather than the path that I'm passing it. So when I run the server action on the |
#50848 should fix this issue, you can test again once a new canary release is out, thanks! |
Should be included in |
@shuding Sorry for not getting back, I didn't see the "let me know if it's fixed". It is fixed and working great 👍🏻 |
Just confirming it now works with |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
app dir
server actions
revalidatePath
Link to the code that reproduces this issue or a replay of the bug
https://github.com/Abyrd9/nextjs-revalidate-path-bug
To Reproduce
Sorry that there's db setups involved but I wasn't sure how else to get the reproduction I wanted.
npm run dev
and navigate tohttp://localhost:3000/
Click the "Add New" button and then type in any sort of text and submit it.
Describe the Bug
When calling a server action that is running revalidatePath on a specific path, I would expect that path to re-run it's queries and return with fresh data. Instead if stays cached.
When submitting the form (located in
/src/components/dialog.tsx
) we call a server action (located in/src/components/dialog.actions.ts
) in which we run the revalidatePath function on the paths/
(base path) and/?create=true
(dialog form path), but the neither the base path nor the dialog path revalidate, they both keep the stale data unless the default cache time runs out or you hard refresh.Expected Behavior
When Submitting the form on the
/?create=true
url, the base url/
and the dialog url/?create=true
should revalidate and run their queries again to get the newly created post.Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: