The issue I am seeing appears to be related to https://github.com/gatsbyjs/gatsby/issues/4216. I am also getting the same error of "TypeErorr: Cannot read property 'internal' of undefined". The difference is I only see the error when updating existing content in Contentful such as changing the publishDate or slug on one of my posts.
Just like the original issue if I pin Gatsby to 1.9.209 everything seems to work as expected.
(Apologies that this involves Contentful so a few more steps to reproduce)
git clone https://github.com/ryanwiemer/gatsby-starter-gcn.gitv1 branchnpm inpm run setupgatsby develop - 1st time it worksgatsby develop again and you will see the error now. If you clear out the the .cache folder it will work again. I assume something is not getting cleared correctly from the cache. error UNHANDLED REJECTION
TypeError: Cannot read property 'internal' of undefined
- build-node-types.js:190
[gatsby-starter-gcn]/[gatsby]/dist/schema/build-node-types.js:190:27
- lodash.js:489 arrayAggregator
[gatsby-starter-gcn]/[lodash]/lodash.js:489:34
- lodash.js:4835 Function.groupBy
[gatsby-starter-gcn]/[lodash]/lodash.js:4835:16
- lodash.js:4380
[gatsby-starter-gcn]/[lodash]/lodash.js:4380:28
- lodash.js:675 arrayReduce
[gatsby-starter-gcn]/[lodash]/lodash.js:675:21
- lodash.js:4379 baseWrapperValue
[gatsby-starter-gcn]/[lodash]/lodash.js:4379:14
- lodash.js:9042 LodashWrapper.wrapperValue
[gatsby-starter-gcn]/[lodash]/lodash.js:9042:14
- build-node-types.js:191 createNodeFields
[gatsby-starter-gcn]/[gatsby]/dist/schema/build-node-types.js:191:16
- build-node-types.js:82 fields
[gatsby-starter-gcn]/[gatsby]/dist/schema/build-node-types.js:82:26
- Array.forEach
- Array.forEach
- Array.forEach
Thanks for the detailed report! Confirming that I can replicate this. If anyone wants to investigate further, I can add you to my test Contentful space - send a message to m-allanson on the ReactiFlux Discord. Or it's fairly quick to set up your own one.
So gatsby-source-contentful creates Markdown children nodes before creating Post node - this cause new code that recursively delete children nodes to remove newly created children nodes. This will probably need some changes in that source plugin to delay creating children nodes.
@pieh @KyleAMathews
Is this change already available? I updated my dependencies and I am still seeing the issue.
My test project: https://github.com/0xsven/test-gatsby-contentful
@0xsven This change is published in 1.3.43 . I can no longer reproduce it, so maybe your issue is different? Do you get same error?
@pieh Yes I still have it. My dependencies:
"gatsby": "^1.9.231",
"gatsby-source-contentful": "^1.3.43",
EDIT:
I assume it has to do with the content model that my contentful project has. It is the example project that contentful creates once you login the first time.
@0xsven your issue is different than the one reported here even if it manifest with similar error. I did reproduce problem with Your config. Which example project did you use for contentful? Tried to reproduce it with example projects on contentful, but all 4 of them (example app, product catalogue, photo gallery and blog) works fine out of the box.
It would be good if you would create separate issue with more details about your contenful setup. This in particular seems to fail in ContentfulLayout type because contentModules fields are all empty and it expect not to be.
Think I nailed down the problem with “internal of undefined” still occuring in some cases.
The reason it is happening for me is because there is an invalid entity reference. So for example, You explicitly link entity A to entity B creating an implicit link from B. Then you go back and delete entity A, but it doesn’t delete the implicit link.
The generate functions in normalize are suppose to be deleting the invalid fields on yhe entries. But where the exceptions is thrown in create nodes, it occurs on an entity where invalid links have been removed, but it still has the key field. So it has the field “[name]___node” with value that is an empty array. Opposed to other entities without any value in that field initially still not having that field.
I am having a similar issue. Everything works fine when adding new content. But when i edit existing content i get the following error on build:
source and transform nodescontentTypes fetched 3
error Plugin gatsby-source-contentful returned an error
TypeError: getNode is not a function
- gatsby-node.js:90
[dcancel]/[gatsby-source-contentful]/gatsby-node.js:90:37
- Array.forEach
- gatsby-node.js:89 _callee$
[dcancel]/[gatsby-source-contentful]/gatsby-node.js:89:16
- next_tick.js:150 process._tickCallback
internal/process/next_tick.js:150:11
â ‚ source and transform nodes
Anyone knows the solutions for this one?
I had similar problems after editing content in Dato. This solved it for merm -rf .cache public.
I was facing the same issue today. I fixed it by just deleting the .cache folder.
Most helpful comment
I was facing the same issue today. I fixed it by just deleting the
.cachefolder.