WebDevStudios / nextjs-wordpress-starter

A headless starter for WordPress powered by Next.js.
https://webdevstudios.github.io/nextjs-wordpress-starter/
GNU General Public License v2.0
737 stars 129 forks source link

Fix "post not found" and error handling [BLOCKED] #155

Closed ravewebdev closed 2 years ago

ravewebdev commented 3 years ago

Our custom permalink structure seems to be causing weird errors when querying by slug/URI: https://github.com/wp-graphql/wp-graphql/issues/1639. When attempting to query a non-existent post, GraphQL is throwing an error instead of returning null.

Once this is fixed, getPostTypeStaticProps should be refactored, specifically regarding pageData.error:

if (!error && !post) {
    return {
        notFound: true
    }
}

This will then render the 404 page, but actual errors will show the Next.js error component instead.

ravewebdev commented 3 years ago

Issue is still occurring as of WP GraphQL v1.3.2.

rodrigo-arias commented 3 years ago

Hi @ravewebdev thanks for your great work on this. I am having an issue and was wondering if it is the behavior you describe here. While browsing my site in some moments, requests to pages that worked begin to fail as in the following screenshot

CleanShot 2021-07-09 at 13 03 44

After some time I can refresh the page and the requests work again. I am hosted on WP Engine and there are no errors there. I'm not sure if this issue may be related or #153 but the strange thing is that it happens intermittently. Maybe with your experience you have noticed something similar. Thanks!

ravewebdev commented 3 years ago

@rodrigo-arias I can't say for sure but it's possible your issue is related to one of these two GraphQL plugin bugs. Is the issue occurring with specific pages or post types, or does it appear random? Have you tried changing the permalink structure (e.g., to "Post name") to see if the issue still occurs? It could also be a timeout issue between your frontend and your WP Engine site; do you have a local copy for testing, and if so, does the issue occur there?

rodrigo-arias commented 3 years ago

@ravewebdev thank you for your input. After researching those options it seems that WP Engine is not able to handle all requests even when it's just me doing QA. The Apollo query cache works fine, I also have the WP Engine object cache enabled, but I still get 504 errors when the PHP workers and the backlog queue are full. I share some articles that were useful to me, in case they are useful to someone else

Just curious, are you using a different architecture solution vs. a monolithic WordPress? I'm somewhat surprised that having less than 200 pages the server cannot handle the uncached requests.

ravewebdev commented 3 years ago

Original issue is still occurring as of WP GraphQL v1.6.5.