question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[gatsby-source-contentful] - Build fails when entries reference eachother

See original GitHub issue

Description

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

  1. Create a Content Type with field that is a reference. Here is an example we have: image

  2. 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.

  3. 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:24 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
axe312gercommented, Jun 23, 2020

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. Thanks

1reaction
Jimmydaleclevelandcommented, Jun 19, 2020

I ran an update on that repro for gatsby, which bumped it to 2.23.6, and did the same with my global gatsby 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Common Errors - Gatsby
This guide is meant as a reference for common errors that have tripped up other Gatsby users. Problems with the cache. Running a...
Read more >
gatsby-source-contentful - npm
Gatsby source plugin for building websites using the Contentful CMS as a data source. Latest version: 8.3.0, last published: 16 hours ago.
Read more >
Building Rise of the Robots with Gatsby and Contentful
Hi there! I recently built Rise of the Robots using Gatsby + Rive to demonstrate how Jamstack creativity and performance can co-exist ...
Read more >
Using Contentful and Gatsby Together - Learn With Jason
You can also reference other entries inside of the editor. ... And then, let's see, we wanna resolve to gatsby-source-contentful. In our options,...
Read more >
Rendering rich text with Gatsbyjs and Contentful using gatsby ...
The problem was that I needed to parse the JSON, and step down the object into the content array. Here's the component: function...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found