gatsby: Intermittent/inconsistent build/develop errors

Firstly really loving Gatsby, it’s awesome!

Description

There a 2 different error messages I have been getting on my local development/production builds which appear to be intermittent and inconsistent. Firstly, if there is a preference to open an issue for each separate one I will be happy to do so. Just let me know:)

Steps to reproduce

Unfortunately I have no clue how to reproduce these issues for Error 1 and Error 2 , they seem to occur between code changes and re running gatsby develop or gatsby build

Here is the gatsby project for reference if need be.

Errors

On gatsby develop or gatsby build these errors may occur from time to time.

Error 1

  TypeError: Cannot read property 'children' of undefined

  - actions.js:50 children.concat.children.map.child
    [app-web]/[gatsby]/dist/redux/actions.js:50:39

  - Array.map

  - actions.js:49 findChildrenRecursively
    [app-web]/[gatsby]/dist/redux/actions.js:49:42

  - actions.js:301 actions.deleteNode.args
    [app-web]/[gatsby]/dist/redux/actions.js:301:29

  - redux.js:468
    [app-web]/[gatsby]/[redux]/lib/redux.js:468:35

  - source-nodes.js:77 staleNodes.forEach.node
    [app-web]/[gatsby]/dist/utils/source-nodes.js:77:34

  - Array.forEach

  - source-nodes.js:77
    [app-web]/[gatsby]/dist/utils/source-nodes.js:77:18

  - Generator.next

  - util.js:16 tryCatcher
    [app-web]/[bluebird]/js/release/util.js:16:23

  - promise.js:512 Promise._settlePromiseFromHandler
    [app-web]/[bluebird]/js/release/promise.js:512:31

  - promise.js:569 Promise._settlePromise
    [app-web]/[bluebird]/js/release/promise.js:569:18

  - promise.js:614 Promise._settlePromise0
    [app-web]/[bluebird]/js/release/promise.js:614:10

  - promise.js:694 Promise._settlePromises
    [app-web]/[bluebird]/js/release/promise.js:694:18

  - async.js:138 _drainQueueStep
    [app-web]/[bluebird]/js/release/async.js:138:12

  - async.js:131 _drainQueue
    [app-web]/[bluebird]/js/release/async.js:131:9

  - async.js:147 Async._drainQueues
    [app-web]/[bluebird]/js/release/async.js:147:5

  - async.js:17 Immediate.Async.drainQueues
    [app-web]/[bluebird]/js/release/async.js:17:14

Work Around

Deleting the .cache folder and rebuilding/ rerunning dev appears to fix this issue.

Error 2

error UNHANDLED REJECTION


  TypeError: Cannot read property 'internal' of undefined

  - build-node-types.js:67 _.flatMap.groupBy.node
    [app-web]/[gatsby]/dist/schema/build-node-types.js:67:84

  - lodash.js:497 arrayAggregator
    [app-web]/[lodash]/lodash.js:497:34

  - lodash.js:4829 Function.groupBy
    [app-web]/[lodash]/lodash.js:4829:16

  - lodash.js:4374
    [app-web]/[lodash]/lodash.js:4374:28

  - lodash.js:683 arrayReduce
    [app-web]/[lodash]/lodash.js:683:21

  - lodash.js:4373 baseWrapperValue
    [app-web]/[lodash]/lodash.js:4373:14

  - lodash.js:9052 LodashWrapper.wrapperValue
    [app-web]/[lodash]/lodash.js:9052:14

  - build-node-types.js:67 groupChildNodesByType
    [app-web]/[gatsby]/dist/schema/build-node-types.js:67:140

  - build-node-types.js:123 inferChildFields
    [app-web]/[gatsby]/dist/schema/build-node-types.js:123:28

  - build-node-types.js:137 inferFields
    [app-web]/[gatsby]/dist/schema/build-node-types.js:137:23

  - build-node-types.js:187 fields
    [app-web]/[gatsby]/dist/schema/build-node-types.js:187:19

  - Array.forEach

  - Array.forEach

Work Around

Again deleting the .cache folder and running the development server or rebuilding fixes this issue.

Expected result

To be able to run the development server consistently and or run a build

Actual result

Not those things What happened. Things broke 😦

Environment

We run our app on openshift in production. For local dev, we run on docker which is pretty close to the openshift image.

local development

System:
    OS: Linux 4.9 Debian GNU/Linux 8 (jessie) 8 (jessie)
    CPU: (6) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Shell: 4.3.30 - /bin/bash
  Binaries:
    Node: 8.12.0 - /usr/local/bin/node
    Yarn: 1.9.4 - /usr/local/bin/yarn
    npm: 6.4.1 - /usr/local/bin/npm
  Languages:
    Python: 2.7.9 - /usr/bin/python
  npmPackages:
    gatsby: ^2.0.64 => 2.0.64
    gatsby-plugin-emotion: ^3.0.1 => 3.0.1
    gatsby-plugin-favicon: ^3.1.4 => 3.1.4
    gatsby-plugin-google-analytics: ^2.0.8 => 2.0.8
    gatsby-plugin-lunr: ^1.3.0 => 1.3.0
    gatsby-plugin-offline: ^2.0.18 => 2.0.19
    gatsby-plugin-postcss: ^2.0.2 => 2.0.2
    gatsby-plugin-react-helmet: ^3.0.4 => 3.0.4
    gatsby-plugin-sharp: ^2.0.14 => 2.0.15
    gatsby-plugin-styled-components: ^3.0.4 => 3.0.4
    gatsby-remark-autolink-headers: ^2.0.12 => 2.0.12
    gatsby-remark-images: ^3.0.1 => 3.0.1
    gatsby-remark-prismjs: ^3.1.4 => 3.1.4
    gatsby-source-filesystem: ^2.0.11 => 2.0.11
    gatsby-source-github-api: 0.0.3 => 0.0.3
    gatsby-transformer-json: ^2.1.6 => 2.1.6
    gatsby-transformer-remark: ^2.1.15 => 2.1.15
    gatsby-transformer-sharp: ^2.1.9 => 2.1.9
    gatsby-transformer-yaml: ^2.1.6 => 2.1.6
  npmGlobalPackages:
    gatsby-cli: 2.4.8

Even running on my local machine i still get the same issue

System:
    OS: macOS 10.14.2
    CPU: x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 8.12.0 - /usr/local/bin/node
    npm: 6.5.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 71.0.3578.98
    Safari: 12.0.2
  npmPackages:
    gatsby: ^2.0.64 => 2.0.91
    gatsby-plugin-emotion: ^3.0.1 => 3.0.1
    gatsby-plugin-favicon: ^3.1.4 => 3.1.5
    gatsby-plugin-google-analytics: ^2.0.8 => 2.0.9
    gatsby-plugin-lunr: ^1.3.0 => 1.3.0
    gatsby-plugin-offline: ^2.0.18 => 2.0.21
    gatsby-plugin-postcss: ^2.0.2 => 2.0.2
    gatsby-plugin-react-helmet: ^3.0.4 => 3.0.5
    gatsby-plugin-sharp: ^2.0.14 => 2.0.17
    gatsby-plugin-styled-components: ^3.0.4 => 3.0.4
    gatsby-remark-autolink-headers: ^2.0.12 => 2.0.12
    gatsby-remark-images: ^3.0.1 => 3.0.1
    gatsby-remark-prismjs: ^3.1.4 => 3.2.0
    gatsby-source-filesystem: ^2.0.11 => 2.0.16
    gatsby-source-github-api: 0.0.3 => 0.0.3
    gatsby-transformer-json: ^2.1.6 => 2.1.7
    gatsby-transformer-remark: ^2.1.15 => 2.2.0
    gatsby-transformer-sharp: ^2.1.9 => 2.1.10
    gatsby-transformer-yaml: ^2.1.6 => 2.1.7
  npmGlobalPackages:
    gatsby-cli: 2.4.1
    gatsby-remark-code-titles: 1.0.2

I’d think that this would have to be a caching issue somewhere. I know for a fact in production, in our openshift environment we create a new image for each PR (as well as any new code changes pushed to the PR) and so the call to gatsby build in production never fails. I don’t claim to be an expert, it could very well be something in our codebase but I don’t think I am modifying any of the Gatsby build/develop objects in anyway.

And again to clarify this issue has been only happening in development when running gatsby build or gatsby develop

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 20 (12 by maintainers)

Most upvoted comments

Nothing so far, i still get it inconsistently. One thought is that it is perhaps tied to switching branches in git. The .cache folder is ignored and so perhaps mixing those up is causing this issue. As i mentioned before, however, my work around of deleting the cache has been working great so far.

I ran into the same issue as well. I did delete a folder within /pages (a page and a css file), while gatsby develop was running. When I restarted gatbsy develop, I got TypeError: Cannot read property 'children' of undefined. Deleting rm -rf .cache and restarting gatsby develop solved the issue.

took a quick look. The only suspect i’d see from your code is https://github.com/MantasMikal/gatsby-source-instagram-all/blob/master/src/sourceNodes.js#L13

where you delete a property from a configuration object. Other than that it looks pretty normal. My local plugin is quite the behemoth but at the end of the day it does the same thing as all source plugins which is generate nodes by calling the createNode method.