question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Gatsby-plugin-sitemap failing in post build

See original GitHub issue

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,

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

28reactions
ediblecodecommented, May 14, 2021

In my case the option exclude has been renamed to excludes in v4 - note the trailing s!

12reactions
LarsEjaascommented, May 15, 2021

In my case the option exclude has been renamed to excludes in v4 - note the trailing s!

Thanks a lot ediblecode!!

That’s it!!

I changed exclude to excludes and my build is now completed without any errors!

Read more comments on GitHub >

github_iconTop Results From Across the Web

gatsby-plugin-sitemap not excluding nested folders
Show activity on this post. I think you miss the only workaround which may work: { resolve: 'gatsby-plugin-sitemap', options: { output: '/', ...
Read more >
gatsby-plugin-sitemap
Create a sitemap for your Gatsby site. Please note: This plugin only generates output when run in production mode! To test your sitemap,...
Read more >
How to generate sitemap.xml on a Gatsby site? - YouTube
This video describes how to generate sitemap. xml on a Gatsby site and adjust the parameters of the used plugin. It also shows...
Read more >
React/Gatsby starter deployment error on run build: "Failed ...
I've just built a new site using a Gatsby starter, and it's supposed to deploy to “https://www.dianemarie.dev.” I previously had a different ...
Read more >
Gatsby Changelog | 5.3.0
gatsby -source-drupal : Fix not found image urls failing builds, ... chuckreynolds: sitemap plugin readme has incorrect array name reference PR #35659 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found