Skip to content

Gatsby-plugin-sitemap failing in post build #31416

@LarsEjaas

Description

@LarsEjaas

Description

I just updated my Gatsby plugin sitemap to v. 4.1 and it is now failing when building the page.

Steps to reproduce

I haven't changed any settings on my page - this is how I integrate the plugin in gatsby-config.js:

{
      resolve: `gatsby-plugin-sitemap`,
      options: {
        output: `/sitemap.xml`,
        // Exclude specific pages or groups of pages using glob parameters
        exclude: [
          `/en/offline-plugin-app-shell-fallback/`,
          `/en/privacy-policy`,
          `/privacy-policy`,
          `/besked-modtaget/`,
          `/en/besked-modtaget/`,
          `/en/404/`,
          `/en/404.html`,
          `/en/artikler/artikler-kommer-snart`,
          `/artikler/artikler-kommer-snart`,
        ],
      },
    },

Expected result

Page should build XML sitemap

Actual result

Gatsby is throwing the following error in build:

 ERROR #11321  PLUGIN

"gatsby-plugin-sitemap" threw an error while running the onPostBuild lifecycle:

Body must be a string. Received: undefined.

  38 |             output = _ref2.output, entryLimit = _ref2.entryLimit, query = _ref2.query, excludes = _ref2.excludes, resolveSiteUrl = _ref2.resolveSiteUrl, resolvePagePath = _ref2.resolvePagePath, resolvePages = _ref2.resolvePages,
filterPages = _ref2.filterPages, serialize = _ref2.serialize;
  39 |             _context.next = 4;
> 40 |             return graphql(query);
     |                    ^
  41 |
  42 |           case 4:
  43 |             _yield$graphql = _context.sent;

File: node_modules\gatsby-plugin-sitemap\gatsby-node.js:40:20



  Error: Body must be a string. Received: undefined.

  - graphql-runner.ts:90 GraphQLRunner.parse
    [portfolio]/[gatsby]/src/query/graphql-runner.ts:90:34

  - graphql-runner.ts:173 GraphQLRunner.query
    [portfolio]/[gatsby]/src/query/graphql-runner.ts:173:27

  - create-graphql-runner.ts:57 
    [portfolio]/[gatsby]/src/bootstrap/create-graphql-runner.ts:57:8

  - gatsby-node.js:40 _callee$
    [portfolio]/[gatsby-plugin-sitemap]/gatsby-node.js:40:20

  - new Promise

Environment


  System:
    OS: Windows 10 10.0.19041
    CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
  Binaries:
    Node: 15.0.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 7.0.3 - C:\Program Files\nodejs\npm.CMD
  Languages:
    Python: 3.9.0 - /c/Python39/python
  Browsers:
    Chrome: 90.0.4430.212
    Edge: Spartan (44.19041.906.0), Chromium (90.0.818.56)
  npmPackages:
    gatsby: ^3.2.0 => 3.5.0 
    gatsby-background-image: ^1.5.0 => 1.5.3 
    gatsby-cli: ^3.2.0 => 3.5.0 
    gatsby-image: ^3.2.0 => 3.5.0 
    gatsby-plugin-brotli: ^2.0.0 => 2.0.0 
    gatsby-plugin-exclude: ^1.0.2 => 1.0.2 
    gatsby-plugin-force-trailing-slashes: ^1.0.5 => 1.0.5 
    gatsby-plugin-image: ^1.2.0 => 1.5.0 
    gatsby-plugin-manifest: ^3.2.0 => 3.5.0 
    gatsby-plugin-offline: ^4.2.0 => 4.5.0 
    gatsby-plugin-postcss: ^4.2.0 => 4.5.0 
    gatsby-plugin-preact: ^5.2.0 => 5.5.0 
    gatsby-plugin-react-helmet: ^4.2.0 => 4.5.0 
    gatsby-plugin-react-i18next: ^1.1.1 => 1.1.1 
    gatsby-plugin-react-svg: ^3.0.0 => 3.0.1 
    gatsby-plugin-recaptcha: ^1.0.5 => 1.0.5 
    gatsby-plugin-robots-txt: ^1.5.5 => 1.6.2 
    gatsby-plugin-sharp: ^3.2.0 => 3.5.0 
    gatsby-plugin-sitemap: 4.1 => 4.1.0 
    gatsby-plugin-transition-link: ^1.20.5 => 1.20.5 
    gatsby-remark-external-links: ^0.0.4 => 0.0.4 
    gatsby-remark-footnotes: ^0.0.8 => 0.0.8 
    gatsby-remark-images: 5.2 => 5.2.0 
    gatsby-remark-prismjs: 5.2 => 5.2.0 
    gatsby-remark-reading-time: ^1.1.0 => 1.1.0 
    gatsby-source-filesystem: ^3.2.0 => 3.5.0 
    gatsby-transformer-remark: 4.2 => 4.2.0 
    gatsby-transformer-sharp: ^3.2.0 => 3.5.0 
  npmGlobalPackages:
    gatsby-cli: 3.4.1

I use the following flags in gatsby-config:

    FAST_REFRESH: true,
    PRESERVE_WEBPACK_CACHE: true,

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugAn issue or pull request relating to a bug in Gatsby

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions