gatsbyjs/gatsby-source-wordpress-experimental

UNHANDLED REJECTION error.includes is not a function on Netlify build

Closed this issue · 1 comments

Hi all,

first of all, thank you for this great plugin! I am really loving it so far. :-) But now I ran into some problems, hopefully you can help… This error happens on several of my websites. It occurs in combination with #264

I have migrated multiple sites to the newer gatsby-source-wordpress-experimental plugin and now get the following errors while building.

  • I tested the build on Netlify
  • Worked before with regular gatsby-source-wordpress plugin, which worked fine.

App setup:

  • gatsby-source-wordpress-experimental v. ^2.0.1
  • gatsby-plugin-netlify-cache v. ^1.2.0 - idk if that matters.
  • I use the following gatsby-source-wordpress-experimental options:
{
      resolve: 'gatsby-source-wordpress-experimental',
      options: {
        url: config.graphQLUrl,
        verbose: true,
        schema: {
          queryDepth: 10,
          perPage: 10,
          typePrefix: `Wp`,
          timeout: 50000
        },
        develop: {
          nodeUpdateInterval: 3000,
          hardCacheMediaFiles: false
        },
        production: {
          hardCacheMediaFiles: false
        },
        debug: {
          graphql: {
            showQueryOnError: true,
            showQueryVarsOnError: true,
            copyQueryOnError: true,
            panicOnError: false,
            onlyReportCriticalErrors: true
          }
        },
        excludeFieldNames: [`blocksJSON`, `saveContent`, `user`, `Tag`],
        type: {
          CoreParagraphBlockAttributes: {
            exclude: true
          },
          CoreParagraphBlockAttributesV2: {
            exclude: true
          },
          CorePullquoteBlockAttributes: {
            exclude: true
          }
        }
      }
    },

In gatsby-node.js:

async function createFlexibleContentPages(graphql, actions, reporter) {
  const { createPage } = actions

  const result = await graphql(`
    {
      allWpPage {
        nodes {
          id
          uri
          template {
            ... on WpFlexibleInhalteTemplate {
              templateName
            }
          }
        }
      }
    }
  `)

  if (result.errors) throw result.errors

  const flexibleContentNodes = result.data.allWpPage.nodes || []

  flexibleContentNodes
    .filter((node) => node.template.templateName === "Flexible Inhalte")
    .forEach((node) => {
      const id = node.id
      const path = node.uri !== "/startseite/" ? node.uri : "/"
      console.log("createFlexibleContentPages -> path", path)

      reporter.info(`Creating flexible content page for ${path}`)

      createPage({
        path,
        component: require.resolve("./src/templates/FlexibleContent.js"),
        context: { id },
      })
    })
}

exports.createPages = async ({ graphql, actions, reporter }) => {
  await createFlexibleContentPages(graphql, actions, reporter)
}

Build command in package.json:

"build": "GATSBY_CONCURRENT_DOWNLOAD=2 gatsby build; netlify-lambda build functions",

WordPress backend setup:

  • WPGatsby v. 0.5.4
  • WPGraphQL v. 0.14.0
  • WPGraphQL for Advanced Custom Fields v. 0.3.5
  • WP GraphQL Polylang v. 0.5.0
  • Webhook Netlify Deploy 1.1.3 for deployment on Netlify

I tried:

  • Clearing cache and re-building, which works.
  • Playing with schema.queryDepth and schema.perPage - without luck.
  • Tuning down concurrent downloads with GATSBY_CONCURRENT_DOWNLOAD=2 flag in the package build command - doesn't help.

I get the following errors:

2:58:42 PM: error UNHANDLED REJECTION error.includes is not a function
2:58:42 PM: 
2:58:42 PM: 
2:58:42 PM:   TypeError: error.includes is not a function
2:58:42 PM:   
2:58:42 PM:   - create-remote-media-item-node.js:61 errorPanicker
2:58:42 PM:     [repo]/[gatsby-source-wordpress-experimental]/src/steps/source-nodes/create-    nodes/create-remote-media-item-node.js:61:11
2:58:42 PM:   
2:58:42 PM:   - create-remote-media-item-node.js:244 Object.onRetry
2:58:42 PM:     [repo]/[gatsby-source-wordpress-experimental]/src/steps/source-nodes/create-    nodes/create-remote-media-item-node.js:244:9
2:58:42 PM:   
2:58:42 PM:   - index.js:33 onError
2:58:42 PM:     [repo]/[async-retry]/lib/index.js:33:17
2:58:42 PM:   
2:58:42 PM:   - index.js:50 catchIt
2:58:42 PM:     [repo]/[async-retry]/lib/index.js:50:11
2:58:42 PM:   
2:58:42 PM:   - task_queues.js:97 processTicksAndRejections
2:58:42 PM:     internal/process/task_queues.js:97:5
2:58:42 PM:   
2:58:42 PM: 
2:58:42 PM: not finished source and transform nodes - 8.897s

Then, the Netlify build finishes and shows the typical "Page Not Found" page. When I clean the cache on Netlify and re-build, the build works. But the problem keeps reappearing randomly but consistently, when building the site.

Thank you for looking into it. I appreciate it.

This was fixed one minor version ahead of the version you're on 😅 https://github.com/gatsbyjs/gatsby-source-wordpress-experimental/blob/master/CHANGELOG.md#202

Upgrading to latest should fix this. Thanks for opening this issue and for using this stack!