GraphQL request failed

Hello,

My builds started failing recently and I think its gatsby-source-plugin but the fails only happen on Netlify.

Here is my log:

7:15:06 PM: Build ready to start
7:15:08 PM: build-image version: ac716c5be7f79fe384a0f3759e8ef612cb821a37 (xenial)
7:15:08 PM: build-image tag: v3.13.0
7:15:08 PM: buildbot version: e552b142336b2b1222a93a4fd4cbed0019c77b46
7:15:08 PM: Building without cache
7:15:08 PM: Starting to prepare the repo for build
7:15:08 PM: No cached dependencies found. Cloning fresh repo
7:15:08 PM: git clone https://github.com/terratrue/terratruehq
7:15:11 PM: Preparing Git Reference refs/heads/staging
7:15:11 PM: Parsing package.json dependencies
7:15:16 PM: Failed to generate package.json data, continuing with build
7:15:17 PM: Starting build script
7:15:17 PM: Installing dependencies
7:15:17 PM: Python version set to 2.7
7:15:18 PM: Downloading and installing node v14.17.4...
7:15:18 PM: Downloading https://nodejs.org/dist/v14.17.4/node-v14.17.4-linux-x64.tar.xz...
7:15:19 PM: Computing checksum with sha256sum
7:15:19 PM: Checksums matched!
7:15:21 PM: Now using node v14.17.4 (npm v6.14.14)
7:15:21 PM: Started restoring cached build plugins
7:15:21 PM: Finished restoring cached build plugins
7:15:21 PM: Attempting ruby version 2.7.2, read from environment
7:15:22 PM: Using ruby version 2.7.2
7:15:22 PM: Using PHP version 5.6
7:15:23 PM: No npm workspaces detected
7:15:23 PM: Started restoring cached node modules
7:15:23 PM: Finished restoring cached node modules
7:15:23 PM: Installing NPM modules using NPM version 6.14.14
7:15:51 PM: > msgpackr-extract@1.0.16 install /opt/build/repo/node_modules/msgpackr-extract
7:15:51 PM: > node-gyp-build
7:15:52 PM: > lmdb@2.2.1 install /opt/build/repo/node_modules/lmdb
7:15:52 PM: > node-gyp-build
7:15:52 PM: > lmdb-store@1.6.14 install /opt/build/repo/node_modules/lmdb-store
7:15:52 PM: > node-gyp-build
7:15:52 PM: > sharp@0.30.2 install /opt/build/repo/node_modules/gatsby-plugin-manifest/node_modules/sharp
7:15:52 PM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
7:15:53 PM: sharp: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.12.2/libvips-8.12.2-linux-x64.tar.br
7:15:54 PM: sharp: Integrity check passed for linux-x64
7:15:54 PM: > sharp@0.30.2 install /opt/build/repo/node_modules/gatsby-plugin-sharp/node_modules/sharp
7:15:54 PM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
7:15:55 PM: sharp: Using cached /opt/buildhome/.npm/_libvips/libvips-8.12.2-linux-x64.tar.br
7:15:56 PM: sharp: Integrity check passed for linux-x64
7:15:56 PM: > sharp@0.30.2 install /opt/build/repo/node_modules/gatsby-transformer-sharp/node_modules/sharp
7:15:56 PM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
7:15:57 PM: sharp: Using cached /opt/buildhome/.npm/_libvips/libvips-8.12.2-linux-x64.tar.br
7:15:57 PM: sharp: Integrity check passed for linux-x64
7:15:58 PM: > sharp@0.29.3 install /opt/build/repo/node_modules/sharp
7:15:58 PM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
7:15:59 PM: sharp: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.11.3/libvips-8.11.3-linux-x64.tar.br
7:16:00 PM: > core-js@3.21.1 postinstall /opt/build/repo/node_modules/core-js
7:16:00 PM: > node -e "try{require('./postinstall')}catch(e){}"
7:16:00 PM: > core-js-pure@3.21.1 postinstall /opt/build/repo/node_modules/core-js-pure
7:16:00 PM: > node -e "try{require('./postinstall')}catch(e){}"
7:16:00 PM: > es5-ext@0.10.58 postinstall /opt/build/repo/node_modules/es5-ext
7:16:00 PM: > node -e "try{require('./_postinstall')}catch(e){}"
7:16:01 PM: > gatsby-telemetry@3.9.1 postinstall /opt/build/repo/node_modules/gatsby-telemetry
7:16:01 PM: > node src/postinstall.js || true
7:16:01 PM: > gatsby-cli@4.9.1 postinstall /opt/build/repo/node_modules/gatsby-cli
7:16:01 PM: > node scripts/postinstall.js
7:16:01 PM: > gatsby@4.7.2 postinstall /opt/build/repo/node_modules/gatsby
7:16:01 PM: > node scripts/postinstall.js
7:16:01 PM: > swiper@8.0.7 postinstall /opt/build/repo/node_modules/swiper
7:16:01 PM: > node -e "try{require('./postinstall')}catch(e){}"
7:16:02 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
7:16:02 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
7:16:02 PM: added 1856 packages from 1047 contributors and audited 1862 packages in 38.739s
7:16:03 PM: 206 packages are looking for funding
7:16:03 PM:   run `npm fund` for details
7:16:03 PM: found 19 vulnerabilities (6 moderate, 6 high, 7 critical)
7:16:03 PM:   run `npm audit fix` to fix them, or `npm audit` for details
7:16:03 PM: NPM modules installed
7:16:04 PM: Started restoring cached go cache
7:16:04 PM: Finished restoring cached go cache
7:16:04 PM: go version go1.14.4 linux/amd64
7:16:04 PM: go version go1.14.4 linux/amd64
7:16:04 PM: Installing missing commands
7:16:04 PM: Verify run directory
7:16:05 PM: ​
7:16:05 PM: ────────────────────────────────────────────────────────────────
7:16:05 PM:   Netlify Build                                                 
7:16:05 PM: ────────────────────────────────────────────────────────────────
7:16:05 PM: ​
7:16:05 PM: ❯ Version
7:16:05 PM:   @netlify/build 26.5.2
7:16:05 PM: ​
7:16:05 PM: ❯ Flags
7:16:05 PM:   baseRelDir: true
7:16:05 PM:   buildId: 624e492a21f08706242af7db
7:16:05 PM:   deployId: 624e492a21f08706242af7dd
7:16:05 PM: ​
7:16:05 PM: ❯ Current directory
7:16:05 PM:   /opt/build/repo
7:16:05 PM: ​
7:16:05 PM: ❯ Config file
7:16:05 PM:   No config file was defined: using default values.
7:16:05 PM: ​
7:16:05 PM: ❯ Context
7:16:05 PM:   production
7:16:05 PM: ​
7:16:05 PM: ❯ Installing plugins
7:16:05 PM:    - @netlify/plugin-gatsby@2.1.4
7:16:23 PM: ​
7:16:23 PM: ❯ Loading plugins
7:16:23 PM:    - @netlify/plugin-gatsby@2.1.4 from Netlify app
7:16:24 PM: ​
7:16:24 PM: ────────────────────────────────────────────────────────────────
7:16:24 PM:   1. @netlify/plugin-gatsby (onPreBuild event)                  
7:16:24 PM: ────────────────────────────────────────────────────────────────
7:16:24 PM: ​
7:16:24 PM: No Gatsby cache found. Building fresh.
7:16:24 PM: ​
7:16:24 PM: (@netlify/plugin-gatsby onPreBuild completed in 10ms)
7:16:24 PM: ​
7:16:24 PM: ────────────────────────────────────────────────────────────────
7:16:24 PM:   2. Build command from Netlify app                             
7:16:24 PM: ────────────────────────────────────────────────────────────────
7:16:24 PM: ​
7:16:24 PM: $ npm run build
7:16:24 PM: > terratruehq@0.1.0 build /opt/build/repo
7:16:24 PM: > gatsby build
7:16:26 PM: warning The following flag(s) found in your gatsby-config.js are not known:
7:16:26 PM: - FUNCTIONS
7:16:26 PM: - FAST_REFRESH
7:16:26 PM: info The following flags are active:
7:16:26 PM: - PRESERVE_FILE_DOWNLOAD_CACHE Β· (Umbrella Issue (https://gatsby.dev/cache-clearing-feedback)) Β· Don't delete the downloaded files cache when changing gatsby-node.js & gatsby-config.js files.
7:16:26 PM: - PARALLEL_SOURCING Β· EXPERIMENTAL Β· (Umbrella Issue (https://gatsby.dev/parallel-sourcing-feedback)) Β· Run all source plugins at the same time instead of serially. For sites with multiple source plugins, this can speedup sourcing and transforming considerably.
7:16:26 PM: Some features you configured with flags are used natively now.
7:16:26 PM: Those flags no longer have any effect and you can remove them from config:
7:16:26 PM: - PRESERVE_WEBPACK_CACHE Β· (Umbrella Issue (https://gatsby.dev/cache-clearing-feedback)) Β· Use webpack's persistent caching and don't delete webpack's cache when changing gatsby-node.js & gatsby-config.js files.
7:16:26 PM: There is one other flag available that you might be interested in:
7:16:26 PM: - DETECT_NODE_MUTATIONS Β· Diagnostic mode to log any attempts to mutate node directly. Helpful when debugging missing data problems. See https://gatsby.dev/debugging-missing-data for more details.
7:16:26 PM: warning Plugin gatsby-plugin-catch-links is not compatible with your gatsby version 4.7.2 - It requires gatsby@^3.0.0-next.0
7:16:26 PM: warning Plugin gatsby-source-wordpress is not compatible with your gatsby version 4.7.2 - It requires gatsby@^3.0.0-next.0
7:16:28 PM: warning Plugin gatsby-plugin-catch-links is not compatible with your gatsby version 4.7.2 - It requires gatsby@^3.0.0-next.0
7:16:28 PM: warning Plugin gatsby-source-wordpress is not compatible with your gatsby version 4.7.2 - It requires gatsby@^3.0.0-next.0
7:16:28 PM: success open and validate gatsby-configs, load plugins - 1.770s
7:16:28 PM: warning gatsby-plugin-force-trailing-slashes: Gatsby now has a trailingSlash option. Learn more at https://gatsby.dev/trailing-slash
7:16:28 PM: success onPreInit - 0.004s
7:16:28 PM: success initialize cache - 0.092s
7:16:28 PM: success copy gatsby files - 0.048s
7:16:29 PM: success Compiling Gatsby Functions - 0.220s
7:16:29 PM: success onPreBootstrap - 0.228s
7:16:29 PM: success  gatsby-source-wordpress  ensuring plugin requirements are met - 0.804s
7:16:30 PM: β €
7:16:30 PM: info  gatsby-source-wordpress 
7:16:30 PM: 	This is either your first build or the cache was cleared.
7:16:30 PM: 	Please wait while your WordPress data is synced to your Gatsby cache.
7:16:30 PM: 	Maybe now's a good time to get up and stretch? :D
7:16:32 PM: success  gatsby-source-wordpress  ingest WPGraphQL schema - 2.203s
7:16:32 PM: success createSchemaCustomization - 3.194s
7:16:32 PM: success  gatsby-source-wordpress  Comment - 0.384s - fetched 0
7:16:32 PM: success  gatsby-source-wordpress  Category - 0.487s - fetched 3
7:16:33 PM: success  gatsby-source-wordpress  ContentType - 0.783s - fetched 6
7:16:33 PM: success  gatsby-source-wordpress  HelpTag - 0.891s - fetched 5
7:16:33 PM: success  gatsby-source-wordpress  MenuItem - 0.922s - fetched 0
7:16:33 PM: success  gatsby-source-wordpress  Menu - 1.080s - fetched 0
7:16:33 PM: success  gatsby-source-wordpress  PostFormat - 1.086s - fetched 0
7:16:33 PM: success  gatsby-source-wordpress  HelpCategory - 1.119s - fetched 15
7:16:34 PM: success  gatsby-source-wordpress  Post - 1.579s - fetched 6
7:16:34 PM: success  gatsby-source-wordpress  Tag - 1.668s - fetched 0
7:16:34 PM: success  gatsby-source-wordpress  Taxonomy - 1.676s - fetched 5
7:16:34 PM: success  gatsby-source-wordpress  PressPage - 1.778s - fetched 2
7:16:34 PM: success  gatsby-source-wordpress  UserRole - 1.895s - fetched 0
7:16:34 PM: success  gatsby-source-wordpress  HelpPost - 1.983s - fetched 43
7:16:34 PM: success  gatsby-source-wordpress  ReleaseNote - 2.180s - fetched 19
7:16:34 PM: success  gatsby-source-wordpress  User - 2.277s - fetched 7
7:16:34 PM: success  gatsby-source-wordpress  MediaItems - 1.738s - fetched 0
7:16:34 PM: success  gatsby-source-wordpress  fetch root fields - 2.326s
7:16:34 PM: success  gatsby-source-wordpress  Page - 2.384s - fetched 17
7:18:48 PM: error  gatsby-source-wordpress  Error: connect ETIMEDOUT 104.198.69.90:443
7:18:48 PM:     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1148:16)
7:18:48 PM: Error occurred while fetching "MediaItem" nodes in inline html.
7:18:48 PM: GraphQL request to https://terratruestage.wpengine.com/graphql failed.
7:18:48 PM: Please ensure the following statements are true
7:18:48 PM:   - your WordPress URL is correct in gatsby-config.js
7:18:48 PM:   - your server is responding to requests
7:18:48 PM:   - WPGraphQL and WPGatsby are installed and active in your WordPress backend
7:18:48 PM:   - Your WordPress debug.log does not contain critical errors
7:18:48 PM: not finished source and transform nodes - 135.731s
7:18:48 PM: not finished  gatsby-source-wordpress  fetching nodes - 135.527s - 128 total
7:18:48 PM: not finished Downloading remote files - 133.438s
7:18:48 PM: not finished  gatsby-source-wordpress  creating nodes - 133.137s
7:18:48 PM: not finished  gatsby-source-wordpress  MediaItem - 133.137s
7:18:48 PM: npm ERR! code ELIFECYCLE
7:18:48 PM: npm ERR! errno 1
7:18:48 PM: npm ERR! terratruehq@0.1.0 build: `gatsby build`
7:18:48 PM: npm ERR! Exit status 1
7:18:48 PM: npm ERR!
7:18:48 PM: npm ERR! Failed at the terratruehq@0.1.0 build script.
7:18:48 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
7:18:48 PM: npm ERR! A complete log of this run can be found in:
7:18:48 PM: npm ERR!     /opt/buildhome/.npm/_logs/2022-04-07T02_18_48_143Z-debug.log
7:18:48 PM: ​
7:18:48 PM: ────────────────────────────────────────────────────────────────
7:18:48 PM:   "build.command" failed                                        
7:18:48 PM: ────────────────────────────────────────────────────────────────
7:18:48 PM: ​
7:18:48 PM:   Error message
7:18:48 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
7:18:48 PM: ​
7:18:48 PM:   Error location
7:18:48 PM:   In Build command from Netlify app:
7:18:48 PM:   npm run build
7:18:48 PM: ​
7:18:48 PM:   Resolved config
7:18:48 PM:   build:
7:18:48 PM:     command: npm run build
7:18:48 PM:     commandOrigin: ui
7:18:48 PM:     environment:
7:18:48 PM:       - ALGOLIA_ADMIN_KEY
7:18:48 PM:       - GATSBY_ALGOLIA_APP_ID
7:18:48 PM:       - GATSBY_ALGOLIA_INDEX_NAME
7:18:48 PM:       - GATSBY_ALGOLIA_SEARCH_KEY
7:18:48 PM:       - GATSBY_TT_ENV
7:18:48 PM:       - NODE_VERSION
7:18:48 PM:     publish: /opt/build/repo/public
7:18:48 PM:     publishOrigin: ui
7:18:48 PM:   plugins:
7:18:48 PM:     - inputs: {}
7:18:48 PM:       origin: ui
7:18:48 PM:       package: '@netlify/plugin-gatsby'
7:18:48 PM: Caching artifacts
7:18:48 PM: Started saving node modules
7:18:48 PM: Finished saving node modules
7:18:48 PM: Started saving build plugins
7:18:48 PM: Finished saving build plugins
7:18:48 PM: Started saving pip cache
7:18:48 PM: Finished saving pip cache
7:18:48 PM: Started saving emacs cask dependencies
7:18:48 PM: Finished saving emacs cask dependencies
7:18:48 PM: Started saving maven dependencies
7:18:48 PM: Finished saving maven dependencies
7:18:50 PM: Creating deploy upload records
7:18:48 PM: Started saving boot dependencies
7:18:48 PM: Finished saving boot dependencies
7:18:48 PM: Started saving rust rustup cache
7:18:48 PM: Finished saving rust rustup cache
7:18:48 PM: Started saving go dependencies
7:18:49 PM: Finished saving go dependencies
7:18:51 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
7:18:50 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
7:18:51 PM: Failing build: Failed to build site
7:18:51 PM: Finished processing build request in 3m43.017960789s

Here is what I have tried:

-Locally and it works but not netlify
-Cloned the repo locally and it works but not on netlify
-Upgraded plugins including Essential Gatsby on Netlify
-Downgraded the gatsby source plugin
-Added more time to gatsby plugin timeout
-Removed changes from last week when it was working including Netlify Referrer-Policy
-Cleared cache a rebuilt with all of the changes above.

My thought is that it may be WordPress itself but then why does this work locally and not Netlify?

Here is where my plugin netlify & Wordpress are at

{
      resolve: `gatsby-source-wordpress`,
      options: {
        // the only required plugin option for WordPress is the GraphQL url.
        url:
          process.env.WPGRAPHQL_URL ||
          `https://www.mywebsite.com/graphql`,
        develop: {
          hardCacheMediaFiles: true,
        },
        type: {
          MediaItem: {
            localFile: {
              requestConcurrency: 200,
            },
          },
        },
        schema: {
          timeout: 1200000,
          perPage: 500,
          requestConcurrency: 50,
        },  
      },
    },
    `gatsby-plugin-netlify`,

Has anyone dealt with anything like this before?

Following up on this. Builds started working correctly this morning.

Not really sure what the case could have been but maybe it’s WordPress (via WPEngine) sending data to Netlify. And that WPEngine may have not operating at 100% yesterday.

Not sure but hopefully this helps someone.

1 Like

Hey there, @byebyers :wave:

Thanks so much for sharing this with us. I am glad everything is working now! If anything like this pops up again, please don’t hesitate to come back and let us know.

Happy building :rocket: