[gatsby-source-contentful] - Build fails when entries reference eachother
See original GitHub issueDescription
When using a content type (on Contentful’s site) with a “reference” field that can point to the same type, it’s possible to create a maximum call stack
error that causes Gatsby to fail to build.
As an example, if you had a “Page” content type that, at any point within, has a possible link to other “Page” types, a sort of circular loop can happen if it ends up pointing back to the origin (e.g. Page A contains a reference to Page B and Page B contains a reference to Page A). This error is thrown:
"gatsby-source-contentful" threw an error while running the sourceNodes lifecycle:
Maximum call stack size exceeded
Subsequent schema errors followed for us, which ended up being red herrings. After finally realizing what the real issue was, I tracked down the origin of this bug to version 2.1.73
(https://www.npmjs.com/package/gatsby-source-contentful/v/2.1.73), as it does not occur in 2.1.72
all the way back to 2.0.46
.
Steps to reproduce
In the Contentful UI
-
Create a Content Type with field that is a reference. Here is an example we have:
-
Create 2 entries of the previous type and make that reference field point to each other. In our situation we wanted a field on “Page” to be able to reference another “Page” for SEO canonical purposes so the URL would automatically update on changes. This also occurred for us when other content types referenced a “Page”, not just a type referencing the same type.
-
Run Gatsby Build and you should get the error shown above.
Expected result
Gatsby should build and the graphql data should be available for the types you created.
Actual result
The build fails with a Maximum call stack size exceeded
Environment
This is mine but others have encountered it on OS X.
System: OS: Linux 4.19 Ubuntu 18.04.4 LTS (Bionic Beaver) CPU: (8) x64 Intel® Core™ i7-6700K CPU @ 4.00GHz Shell: 5.4.2 - /usr/bin/zsh Binaries: Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node Yarn: 1.18.0 - ~/.nvm/versions/node/v12.16.1/bin/yarn npm: 6.13.4 - ~/.nvm/versions/node/v12.16.1/bin/npm
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:24 (6 by maintainers)
The starter Jimmy was using was pretty much out of date. I upgrade the dependencies here: https://github.com/contentful/starter-gatsby-blog/pull/126
So if you run into this, ensure you run the latest versions of
gatsby
&gatsby-source-contentful
before reopening this. ThanksI ran an update on that repro for gatsby, which bumped it to
2.23.6
, and did the same with my globalgatsby
install just to be sure. Both failed the same way.I’ll get some people who haven’t had any of these packages installed on their machine to run it before bugging you again. Thanks for looking at it.