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

Revalidation webhook failure when unpublishing #29

Open
jmsv opened this issue Sep 20, 2022 · 0 comments
Open

Revalidation webhook failure when unpublishing #29

jmsv opened this issue Sep 20, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@jmsv
Copy link
Member

jmsv commented Sep 20, 2022

Happened with blog post, probably happens with events too

Can find webhook logs for this on Sanity dashboard under API tab

HTTP 500 with message "Error revalidating"

Unpublish 'works' in the sense that it'll no longer appear on the homepage or blog page, but the blog post page is still accessible directly via URL

Pretty sure this happens because:

  1. Revalidate is called on the post page URL
  2. getStaticProps is called which tries to load the blog post by slug
  3. This fails because post isn't published

Currently have this code in getStaticProps:

const blogPost = await getBlogPostBySlug(
  context.params?.slug as string | undefined
);

if (!blogPost) return { notFound: true };

I'm guessing (haven't validated that this is correct) that getBlogPostBySlug throws when not found (which fails the revalidate) and !blogPost condition never hits to return the 404

@jmsv jmsv added the bug Something isn't working label Sep 20, 2022
@jmsv jmsv added this to the Before December milestone Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant