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

Hot Reload Intermittent Error / GraphQLError: Cannot read property 'parent' of undefined #5323

Closed
chibicode opened this issue May 8, 2018 · 3 comments
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@chibicode
Copy link

chibicode commented May 8, 2018

Description

My blog (source) keeps getting this error on hot reload after 20-50 hot reloads - not sure exactly how to reproduce it.

Errors:
  GraphQLError: Cannot read property 'parent' of undefined
URL path:
   /posts/...
Plugin:
  Plugin default-site-plugin

The error happens on PostTemplate, which is used by createPage. I'm using allMarkdownRemark because I want to show all other posts on a single post page.

Here's the query:

export const pageQuery = graphql`
  query PostBySlugQuery($slug: String!) {
    site {
      siteMetadata {
        title
        author
        siteUrl
      }
    }
    allMarkdownRemark(sort: { fields: [frontmatter___date], order: DESC }) {
      edges {
        node {
          htmlAst
          excerpt
          fields {
            slug
          }
          frontmatter {
            date(formatString: "MMMM DD, YYYY")
            title
            draft
            tags
            imageAttributionName
            imageAttributionUrl
            twitterId
            image {
              childImageSharp {
                width1200: resolutions(width: 1200, quality: 80) {
                  height
                  src
                  width
                }
                width1000: sizes(maxWidth: 1000, quality: 80) {
                  aspectRatio
                  base64
                  sizes
                  src
                  srcSet
                }
              }
            }
          }
        }
      }
    }
    markdownRemark(fields: { slug: { eq: $slug } }) {
      id
      htmlAst
      excerpt
      fields {
        slug
      }
      frontmatter {
        title
        date(formatString: "MMMM DD, YYYY")
        dateRaw: date
        imageAttributionName
        imageAttributionUrl
        twitterId
        draft
        tags
        image {
          childImageSharp {
            width1200: resolutions(width: 1200, quality: 80) {
              height
              src
              width
            }
            width1000: sizes(maxWidth: 1000, quality: 80) {
              aspectRatio
              base64
              sizes
              src
              srcSet
            }
          }
        }
      }
    }
  }
`

Here's my gatsby config and gatsby node.

  • Gatsby version (npm list gatsby): 1.9.259
  • gatsby-cli version (gatsby --version): 1.9.259
  • Node.js version: 9.7.1
  • Operating System: macOS 10.13.4

It'd be great if someone could point me to how to debug this error... I don't even know which code is running .parent.

@chibicode chibicode changed the title GraphQLError: Cannot read property 'parent' of undefined on hot reload Hot Reload Intermittent Error / GraphQLError: Cannot read property 'parent' of undefined May 8, 2018
@m-allanson
Copy link
Contributor

Urgh, intermittent errors are the worst.

default-site-plugin is the name given to the gatsby-x.js files in the root of your project. So it sounds like the error could be occurring when running your gatsby-node.js file.

That particular error is created in Gatsby's query runner. There's an open PR for adding more info to that error, which could be useful.

You can either dive into the transpiled JS in node_modules/gatsby/dist/internal-plugins/query-runner/query-runner.js, or set up a local Gatsby dev environment to make changes to your Gatsby instal.

@m-allanson m-allanson added the type: question or discussion Issue discussing or asking a question about Gatsby label May 8, 2018
@pieh
Copy link
Contributor

pieh commented May 9, 2018

parent reference there gives 2 potential guesses where this could fail:

in any case as this doesn't happen all the time, it would probably mean that Gatsby tries to resolve fields during some kind of bad state, where node is not defined :/

@KyleAMathews
Copy link
Contributor

Due to the high volume of issues, we're closing out older ones without recent activity. Please open a new issue if you need help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

4 participants