Gatsby: Gatsby Develop crashes with slice error v2.15.24

Created on 25 Sep 2019  路  17Comments  路  Source: gatsbyjs/gatsby

Description

When trying to run dev the build fails after upgrading to Gatsby v2.15.24 from 2.15.22.

```
ERROR

UNHANDLED REJECTION Cannot read property 'slice' of undefined



  TypeError: Cannot read property 'slice' of undefined

  - index.js:138 
    [cco-gatsby-fe]/[gatsby]/dist/query/index.js:138:46

  - lodash.js:497 arrayAggregator
    [cco-gatsby-fe]/[gatsby]/[lodash]/lodash.js:497:34

  - lodash.js:4823 Function.groupBy
    [cco-gatsby-fe]/[gatsby]/[lodash]/lodash.js:4823:16

  - index.js:138 Object.groupQueryIds
    [cco-gatsby-fe]/[gatsby]/dist/query/index.js:138:21

  - develop.js:388 module.exports
    [cco-gatsby-fe]/[gatsby]/dist/commands/develop.js:388:17
### Steps to reproduce

Run gatsby develop

### Expected result

Complete dev build and serve. (For reference, I reverted to 2.15.22 and it worked perfectly)

### Actual result

Error and build fail as shown above

### Environment

Run `gatsby info --clipboard` in your project directory and paste the output here.

| => gatsby info --clipboard

System:
OS: macOS 10.14.6
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.4.0 - /usr/local/bin/node
npm: 6.11.3 - /usr/local/bin/npm
Languages:
Python: 2.7.10 - /usr/bin/python
Browsers:
Chrome: 77.0.3865.90
Safari: 13.0.1
npmPackages:
gatsby: ^2.15.24 => 2.15.24
gatsby-cli: ^2.7.50 => 2.7.50
gatsby-image: ^2.2.21 => 2.2.21
gatsby-plugin-algolia: ^0.3.4 => 0.3.4
gatsby-plugin-create-client-paths: ^2.1.9 => 2.1.9
gatsby-plugin-eslint: ^2.0.5 => 2.0.5
gatsby-plugin-manifest: ^2.2.18 => 2.2.18
gatsby-plugin-material-ui: ^2.1.6 => 2.1.6
gatsby-plugin-netlify: ^2.1.15 => 2.1.15
gatsby-plugin-netlify-cache: ^1.2.0 => 1.2.0
gatsby-plugin-offline: ^3.0.9 => 3.0.9
gatsby-plugin-react-helmet: ^3.1.8 => 3.1.8
gatsby-plugin-remove-serviceworker: ^1.0.0 => 1.0.0
gatsby-plugin-sharp: ^2.2.25 => 2.2.25
gatsby-plugin-styled-components: ^3.1.6 => 3.1.6
gatsby-plugin-web-font-loader: ^1.0.4 => 1.0.4
gatsby-source-drupal: ^3.2.31 => 3.2.31
gatsby-source-filesystem: ^2.1.26 => 2.1.26
gatsby-transformer-sharp: ^2.2.17 => 2.2.17
gatsby-transformer-sqip: ^2.1.28 => 2.1.28

```

confirmed bug

Most helpful comment

I think I see what's the issue, will open PR with hot-fix shortly

All 17 comments

Confirmed. Getting same errors here too with v2.15.24.

Also getting it after reverting back to 2.15.22 and deleting the package-lock file.

Same issue here. In my case, the error seems to be coming from a graphql query in gatsby-node.js.
Worked fine in previous versions of Gatsby v2.

Reverting back to v2.15.22 and removing node_modules, .cache, public and any npm/yarn lock files resolves the issue.


  TypeError: Cannot read property 'slice' of undefined

  - index.js:138 
    [portfolio]/[gatsby]/dist/query/index.js:138:46

  - lodash.js:497 arrayAggregator
    [portfolio]/[lodash]/lodash.js:497:34

  - lodash.js:4823 Function.groupBy
    [portfolio]/[lodash]/lodash.js:4823:16

  - index.js:138 Object.groupQueryIds
    [portfolio]/[gatsby]/dist/query/index.js:138:21

  - develop.js:388 module.exports
    [portfolio]/[gatsby]/dist/commands/develop.js:388:17

  System:
    OS: macOS High Sierra 10.13.6
    CPU: x64 Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.0.0 - ~/.nvm/versions/node/v12.0.0/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v12.0.0/bin/npm
  Browsers:
    Chrome: 75.0.3770.142
    Firefox: 63.0.1
    Safari: 13.0.1
  npmPackages:
    gatsby: ^2.15.19 => 2.15.24 
    gatsby-cli: ^2.7.50 => 2.7.50 
    gatsby-image: ^2.2.20 => 2.2.21 
    gatsby-plugin-react-helmet: ^3.1.8 => 3.1.8 
    gatsby-plugin-sass: ^2.1.15 => 2.1.15 
    gatsby-plugin-sharp: ^2.2.25 => 2.2.25 
    gatsby-remark-copy-linked-files: ^2.1.20 => 2.1.21 
    gatsby-remark-images: ^3.1.23 => 3.1.23 
    gatsby-source-filesystem: ^2.1.26 => 2.1.26 
    gatsby-transformer-remark: ^2.6.24 => 2.6.24 
    gatsby-transformer-sharp: ^2.2.17 => 2.2.17 

Same here 馃憤

Can you provide reproduction? It doesn't happen in few tests I just run with 2.15.24, so I suspect it has to be something specific that trigger this

I get it even with 2.15.22 if I remove my node_modules and lock file and do a fresh npm install.

@pieh Sure! Just use the Infinite Scroll starter:
https://www.gatsbyjs.org/starters/baobabKoodaa/gatsby-starter-infinite-scroll/

Looks to be the use of .slice in the gatsby-node.js file that triggers the error.

@JohnMilazzo Did you pin your gatsby version? What gatsby version did you get after running gatsby info?

Ok, I can reproduce with gatsbyjs.org/starters/baobabKoodaa/gatsby-starter-infinite-scroll - thanks @briangonzalezmia, taking deeper look now

"dependencies": { "dotenv": "^8.1.0", "gatsby": "^2.15.22", "gatsby-source-graphql": "^2.1.15", "react": "^16.9.0", "react-dom": "^16.9.0" },

"dependencies": { "dotenv": "^8.1.0", "gatsby": "^2.15.22", "gatsby-source-graphql": "^2.1.15", "react": "^16.9.0", "react-dom": "^16.9.0" },

"gatsby": "^2.15.22" means you will get [email protected], if you want to pin version you need to use "gatsby": "2.15.22" (no caret character ^ in front of version)

I think I see what's the issue, will open PR with hot-fix shortly

published [email protected] - please let me know if it fixes everyones issues and not just one I used for reproduction

as a note - I think this only happens when you query childImageSharp in your gatsby-node (or maybe in graphiql as well), I will need to investigate more, but for now just added sanity check

Testing now. FWIW, not using childImageSharp in mine.

@pieh Fixed, thanks 馃帀 馃檶

@pieh Bingo! Thank you for the quick resolution!!

Fixed!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rossPatton picture rossPatton  路  3Comments

signalwerk picture signalwerk  路  3Comments

kalinchernev picture kalinchernev  路  3Comments

ghost picture ghost  路  3Comments

KyleAMathews picture KyleAMathews  路  3Comments