gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.19k stars 10.33k forks source link

"gatsby-source-wordpress" threw an error while running the sourceNodes lifecycle while deploying to Netlify #20838

Closed andrewgilliland closed 4 years ago

andrewgilliland commented 4 years ago

Description

I am seeing the error ""gatsby-source-wordpress" threw an error while running the sourceNodes lifecycle", "Cannot read property 'data' of undefined" when I deploy to Netlify. I had looked through a previous issue that was similar, but none of the suggestions fixed this issue.

Steps to reproduce

I am using Local by Flywheel to host my wordpress locally at the url "http://headless.local/". It is pulling in the data into my Gatsby site locally at the url "http://localhost:8000/" on the gatsby develop command and it properly builds on the that gatsby build command.

This is my gatsby-config.js

module.exports = {
  siteMetadata: {
    title: `WordPress + Gatsby`,
    description: `Headless wordpress plus Gatsby.`,
    author: `@andy_gilliland`,
  },
  plugins: [
    `gatsby-plugin-netlify`,
    {
      resolve: `gatsby-source-wordpress`,
      options: {
        baseUrl: `headless.local/`,
        protocol: `http`,
        hostingWPCOM: false,
        useACF: true,
      },
    },
    `gatsby-plugin-react-helmet`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images`,
      },
    },
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `gatsby-starter-default`,
        short_name: `starter`,
        start_url: `/`,
        background_color: `#663399`,
        theme_color: `#663399`,
        display: `minimal-ui`,
        icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
      },
    },
    // this (optional) plugin enables Progressive Web App + Offline functionality
    // To learn more, visit: https://gatsby.dev/offline
    // `gatsby-plugin-offline`,
  ],
}

Expected result

It should deploy to Netlify.

Actual result

This was the point in the Netlify deploy log where the error occurred.

9:23:21 AM: The request failed with error code "ENOTFOUND"
9:23:21 AM: error "gatsby-source-wordpress" threw an error while running the sourceNodes lifecycle:
9:23:21 AM: Cannot read property 'data' of undefined
9:23:21 AM: 
9:23:21 AM:   TypeError: Cannot read property 'data' of undefined
9:23:21 AM:   
9:23:21 AM:   - fetch.js:141 fetch
9:23:21 AM:     [repo]/[gatsby-source-wordpress]/fetch.js:141:21
9:23:21 AM:   
9:23:21 AM:   - next_tick.js:68 process._tickCallback
9:23:21 AM:     internal/process/next_tick.js:68:7
9:23:21 AM:   
9:23:21 AM: 
9:23:21 AM: not finished source and transform nodes - 0.105s
9:23:21 AM: Skipping functions preparation step: no functions directory set
9:23:21 AM: Caching artifacts
9:23:21 AM: Started saving node modules
9:23:21 AM: Finished saving node modules
9:23:21 AM: Started saving pip cache
9:23:21 AM: Finished saving pip cache
9:23:21 AM: Started saving emacs cask dependencies
9:23:21 AM: Finished saving emacs cask dependencies
9:23:21 AM: Started saving maven dependencies
9:23:21 AM: Finished saving maven dependencies
9:23:21 AM: Started saving boot dependencies
9:23:21 AM: Finished saving boot dependencies
9:23:21 AM: Started saving go dependencies
9:23:21 AM: Finished saving go dependencies
9:23:24 AM: Error running command: Build script returned non-zero exit code: 1
9:23:24 AM: Failing build: Failed to build site
9:23:24 AM: failed during stage 'building site': Build script returned non-zero exit code: 1
9:23:24 AM: Finished processing build request in 1m5.054565857s

Environment

System: OS: Windows 10 CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz Binaries: Yarn: 1.17.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: 44.18362.449.0 npmPackages: gatsby: ^2.19.4 => 2.19.4 gatsby-image: ^2.2.39 => 2.2.39 gatsby-plugin-manifest: ^2.2.38 => 2.2.38 gatsby-plugin-netlify: ^2.1.31 => 2.1.31 gatsby-plugin-offline: ^2.2.10 => 2.2.10 gatsby-plugin-react-helmet: ^3.1.21 => 3.1.21 gatsby-plugin-sharp: ^2.4.0 => 2.4.0 gatsby-source-filesystem: ^2.1.46 => 2.1.46 gatsby-source-wordpress: ^3.1.58 => 3.1.58 gatsby-transformer-sharp: ^2.3.13 => 2.3.13

vladar commented 4 years ago

Most likely that Netlify is trying to reach your local site which is not available from their servers (well, because it is local). You should probably have your wordpress site deployed somewhere first and then use it in your worpdpress-source-config for production mode. Have you tried it?

I may be completely missing something here though.

andrewgilliland commented 4 years ago

I have not tried it, but I will. Thanks for the help!

github-actions[bot] commented 4 years ago

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

github-actions[bot] commented 4 years ago

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! 💪💜

ricricucit commented 4 years ago

@andrewgilliland do you have updates?