Skip to content
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

Revalidate "More stories" with a webhook doesn't always work when adding/removing a post #93

Closed
tddostu opened this issue Nov 22, 2022 · 2 comments · Fixed by #94
Closed

Comments

@tddostu
Copy link

tddostu commented Nov 22, 2022

Related Commit 9c45983 (https://nextjs-blog-cms-sanity-v3-m2zs0oidy.sanity.build).

Originally posted by @kmelve in #89 (comment)

Summary

When updating a post or author, revalidation works as expected across the homepage and existing posts. However, when adding or removing/unpublishing a post entirely, sometimes only the homepage path gets revalidated. This means the "More stories" section on other exisiting posts doesn't get updated. The deleted/unpublished post also gets left behind and is still accessible.

Sometimes it does work, I can't seem to figure out why.

Video attached shows:

  • Newly deployed site using the deploy button in this repo (as at e43759b)
  • Site with 4 posts with a new 5th post being published, validation of home + all existing posts works (as seen in the function logs on the left)
  • When deleting that 5th post, only the homepage is invalidated, leaving the "More stories" section on all other posts out of date + the removed post still available
  • Adding another new post (Test Post 06), only the homepage gets revalidated, the new post is missing from "More Stories" on all other posts
  • Unpublishing an existing post (Test Post 04) only invalidates the homepage and itself, leaving it in the "More Stories" section on most other posts

Expected behaviour:

  • Adding a new post should add it to the "More stories" section of all other posts.
    • Note that this does reliably happen for me when updating a post, making a new post and then updating it immediately after is my current workaround
  • Removing/Unpublishing a post should:
    • remove it from the "More stories" section of all other posts
    • make it inaccessible from the website as a whole.
nextjs-sanity-revalidate_issue.mp4
@stipsan
Copy link
Member

stipsan commented Nov 22, 2022

First of all, thank you for the super detailed report! 🙌 Secondly, I have to admit I didn't think about the delete case when writing the new logic 🙈

It really helps that you spent all this effort investigating and sharing your findings 🙇

@stipsan
Copy link
Member

stipsan commented Nov 22, 2022

Ok should be solved now @tddostu 😄 If it's not, feel free to reopen! ☺️

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants