Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

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

Closed
ravewebdev opened this issue Jan 29, 2021 · 5 comments · Fixed by #871
Closed

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

ravewebdev opened this issue Jan 29, 2021 · 5 comments · Fixed by #871
Labels
bug Something isn't working

Comments

@ravewebdev
Copy link
Contributor

Our custom permalink structure seems to be causing weird errors when querying by slug/URI: wp-graphql/wp-graphql#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:

  • We should not be returning the notFound prop if an actual error is encountered. In that case, we should remove the early notFound returns, which will pass error and errorMessage along to _app.js, which will render the Error component.
  • If a post is actually not found, getPostTypeStaticProps should receive (from whichever getter function) no error but a null value for the post prop (I believe this is already the case but should be confirmed). Then we can use notFound, e.g.:
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 ravewebdev added the bug Something isn't working label Jan 29, 2021
@ravewebdev
Copy link
Contributor Author

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

@rodrigo-arias
Copy link

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
Copy link
Contributor Author

@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
Copy link

@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
Copy link
Contributor Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants