Skip to content

gatsby-plugin-sitemap: TypeError: Cannot use 'in' operator to search for 'nodes' in undefined #25019

@janosh

Description

@janosh

Description

plugin-sitemap crashes build:

⠹ onPostBuild

 ERROR #11321  PLUGIN

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

Cannot use 'in' operator to search for 'nodes' in undefined

  40 |           case 9:
  41 |             queryRecords = _context.sent;
> 42 |             filteredRecords = (0, _internals.filterQuery)(queryRecords, excludeOptions, basePath, resolveSiteUrl);
     |                                                          ^
  43 |             urls = serialize(filteredRecords);
  44 | 
  45 |             if (!(!rest.sitemapSize || urls.length <= rest.sitemapSize)) {

File: node_modules/gatsby-plugin-sitemap/gatsby-node.js:42:58



  TypeError: Cannot use 'in' operator to search for 'nodes' in undefined
  
  - internals.js:113 getNodes
    [blog]/[gatsby-plugin-sitemap]/internals.js:113:15
  
  - internals.js:46 filterQuery
    [blog]/[gatsby-plugin-sitemap]/internals.js:46:19
  
  - gatsby-node.js:42 _callee$
    [blog]/[gatsby-plugin-sitemap]/gatsby-node.js:42:58
  
  - task_queues.js:97 processTicksAndRejections
    internal/process/task_queues.js:97:5

Steps to reproduce

My config (see in repo)

{
  resolve: `gatsby-plugin-sitemap`,
  options: {
    output: `/sitemap.xml`,
    query: `{
      site {
        meta: siteMetadata {
          url
        }
      }
      pages: allSitePage {
        nodes {
          path
        }
      }
    }`,
    resolveSiteUrl: ({ site }) => site.meta.url,
    serialize: ({ site, pages }) =>
      pages.nodes.map(node => ({ url: site.meta.url + node.path })),
  }
  ,
},

Environment

  System:
    OS: macOS 10.15.5
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.4.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.4 - /usr/local/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 83.0.4103.97
    Firefox: 77.0.1
    Safari: 13.1.1
  npmPackages:
    gatsby: 2.23.1 => 2.23.1 
    gatsby-image: 2.4.6 => 2.4.6 
    gatsby-plugin-algolia: ^0.11.1 => 0.11.1 
    gatsby-plugin-catch-links: 2.3.4 => 2.3.4 
    gatsby-plugin-favicon: ^3.1.6 => 3.1.6 
    gatsby-plugin-feed: ^2.5.4 => 2.5.4 
    gatsby-plugin-google-analytics: 2.3.3 => 2.3.3 
    gatsby-plugin-lodash: ^3.3.3 => 3.3.3 
    gatsby-plugin-manifest: 2.4.10 => 2.4.10 
    gatsby-plugin-mdx: ^1.2.14 => 1.2.14 
    gatsby-plugin-netlify-cache: ^1.2.0 => 1.2.0 
    gatsby-plugin-offline: 3.2.8 => 3.2.8 
    gatsby-plugin-react-helmet: 3.3.3 => 3.3.3 
    gatsby-plugin-sharp: 2.6.10 => 2.6.10 
    gatsby-plugin-sitemap: ^2.4.5 => 2.4.5 
    gatsby-plugin-styled-components: ^3.3.3 => 3.3.3 
    gatsby-remark-autolink-headers: ^2.3.4 => 2.3.4 
    gatsby-remark-code-titles: ^1.1.0 => 1.1.0 
    gatsby-remark-copy-linked-files: ^2.3.4 => 2.3.4 
    gatsby-remark-embed-video: 3.0.10 => 3.0.10 
    gatsby-remark-emojis: ^0.4.3 => 0.4.3 
    gatsby-remark-images: 3.3.9 => 3.3.9 
    gatsby-remark-katex: ^3.3.3 => 3.3.3 
    gatsby-remark-responsive-iframe: 2.4.4 => 2.4.4 
    gatsby-remark-smartypants: 2.3.3 => 2.3.3 
    gatsby-remark-sub-sup: ^1.0.0 => 1.0.0 
    gatsby-remark-vscode: ^2.1.1 => 2.1.1 
    gatsby-source-filesystem: 2.3.10 => 2.3.10 
    gatsby-transformer-sharp: 2.5.4 => 2.5.4 
    gatsby-transformer-yaml: 2.4.3 => 2.4.3 

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedIssue with a clear description that the community can help with.stale?Issue that may be closed soon due to the original author not responding any more.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