Gatsby: Maximum call stack size exceeded and error trying to infer a GraphQL type

Created on 10 Sep 2019  Â·  5Comments  Â·  Source: gatsbyjs/gatsby

Description

Builds are failing with several errors from gatsby-source-contentful, including:

Maximum call stack size exceeded

and

UNHANDLED REJECTION Encountered an error trying to infer a GraphQL type for: `my index page___NODE`. There is no corresponding node with the `id` field matching: "49592856-eefe-5c84-bdef-341d8f1c4206,c5636aa0-e388-50f3-a49b-3a88b632cd0e,268ea443-6fd9-5478-8f95-b7a0fb4f2a41,ffa853e7-692b-55c0-989a-ed9f51c287aa,db1d360f-f537-57ce-bd33-ae0923a676f4,7870ccfb-8a9b-5d23-b718-731685bfd7ed,3ccb8cb6-e215-53d4-954d-b21f5bb28f70,16bd91e0-daf5-5820-bace-3322ebcbe950".

Steps to reproduce

I'm not sure how this could be reproduced, I think our data in Contentful may have a circular reference but I'm unable to find it

Expected result

The build should succeed

Actual result

The build fails with this output (which has been slightly sanitized for Github):

```Using development env vars
success open and validate gatsby-configs - 0.543 s
success load plugins - 0.690 s
success onPreInit - 0.020 s
success initialize cache - 0.021 s
success copy gatsby files - 0.056 s
success onPreBootstrap - 0.019 s
Starting to fetch data from Contentful
Fetching default locale
default locale is : en-CA
contentTypes fetched 31
Updated entries 1003
Deleted entries 0
Updated assets 132
Deleted assets 0
Fetch Contentful data: 3530.739ms

ERROR #11321 PLUGIN

"gatsby-source-contentful" threw an error while running the sourceNodes lifecycle:

Maximum call stack size exceeded

RangeError: Maximum call stack size exceeded

  • Object

  • lodash.js:3067 baseGetTag
    [public-site]/[gatsby]/[lodash]/lodash.js:3067:51

  • lodash.js:12037 Function.isPlainObject
    [public-site]/[gatsby]/[lodash]/lodash.js:12037:35

  • sanitize-node.js:11 sanitizeNode
    [public-site]/[gatsby]/dist/db/sanitize-node.js:11:27

  • sanitize-node.js:23 _.each
    [public-site]/[gatsby]/dist/db/sanitize-node.js:23:25

  • lodash.js:4905
    [public-site]/[gatsby]/[lodash]/lodash.js:4905:15

  • lodash.js:2990 baseForOwn
    [public-site]/[gatsby]/[lodash]/lodash.js:2990:24

  • lodash.js:4874
    [public-site]/[gatsby]/[lodash]/lodash.js:4874:18

  • lodash.js:9342 Function.forEach
    [public-site]/[gatsby]/[lodash]/lodash.js:9342:14

  • sanitize-node.js:17 sanitizeNode
    [public-site]/[gatsby]/dist/db/sanitize-node.js:17:7

  • sanitize-node.js:23 _.each
    [public-site]/[gatsby]/dist/db/sanitize-node.js:23:25

  • lodash.js:4905
    [public-site]/[gatsby]/[lodash]/lodash.js:4905:15

  • lodash.js:2990 baseForOwn
    [public-site]/[gatsby]/[lodash]/lodash.js:2990:24

  • lodash.js:4874
    [public-site]/[gatsby]/[lodash]/lodash.js:4874:18

  • lodash.js:9342 Function.forEach
    [public-site]/[gatsby]/[lodash]/lodash.js:9342:14

  • sanitize-node.js:17 sanitizeNode
    [public-site]/[gatsby]/dist/db/sanitize-node.js:17:7

  • sanitize-node.js:23 _.each
    [public-site]/[gatsby]/dist/db/sanitize-node.js:23:25

  • lodash.js:4905
    [public-site]/[gatsby]/[lodash]/lodash.js:4905:15

  • lodash.js:2990 baseForOwn
    [public-site]/[gatsby]/[lodash]/lodash.js:2990:24

  • lodash.js:4874
    [public-site]/[gatsby]/[lodash]/lodash.js:4874:18

  • lodash.js:9342 Function.forEach
    [public-site]/[gatsby]/[lodash]/lodash.js:9342:14

  • sanitize-node.js:17 sanitizeNode
    [public-site]/[gatsby]/dist/db/sanitize-node.js:17:7

  • sanitize-node.js:23 _.each
    [public-site]/[gatsby]/dist/db/sanitize-node.js:23:25

  • lodash.js:4905
    [public-site]/[gatsby]/[lodash]/lodash.js:4905:15

  • lodash.js:2990 baseForOwn
    [public-site]/[gatsby]/[lodash]/lodash.js:2990:24

  • lodash.js:4874
    [public-site]/[gatsby]/[lodash]/lodash.js:4874:18

  • lodash.js:9342 Function.forEach
    [public-site]/[gatsby]/[lodash]/lodash.js:9342:14

  • sanitize-node.js:17 sanitizeNode
    [public-site]/[gatsby]/dist/db/sanitize-node.js:17:7

  • sanitize-node.js:23 _.each
    [public-site]/[gatsby]/dist/db/sanitize-node.js:23:25

  • lodash.js:4905
    [public-site]/[gatsby]/[lodash]/lodash.js:4905:15

  • lodash.js:2990 baseForOwn
    [public-site]/[gatsby]/[lodash]/lodash.js:2990:24

  • lodash.js:4874
    [public-site]/[gatsby]/[lodash]/lodash.js:4874:18

  • lodash.js:9342 Function.forEach
    [public-site]/[gatsby]/[lodash]/lodash.js:9342:14

  • sanitize-node.js:17 sanitizeNode
    [public-site]/[gatsby]/dist/db/sanitize-node.js:17:7

  • sanitize-node.js:23 _.each
    [public-site]/[gatsby]/dist/db/sanitize-node.js:23:25

  • lodash.js:4905
    [public-site]/[gatsby]/[lodash]/lodash.js:4905:15

  • lodash.js:2990 baseForOwn
    [public-site]/[gatsby]/[lodash]/lodash.js:2990:24

  • lodash.js:4874
    [public-site]/[gatsby]/[lodash]/lodash.js:4874:18

  • lodash.js:9342 Function.forEach
    [public-site]/[gatsby]/[lodash]/lodash.js:9342:14

  • sanitize-node.js:17 sanitizeNode
    [public-site]/[gatsby]/dist/db/sanitize-node.js:17:7

success source and transform nodes - 6.564 s
success Add explicit types - 0.017 s

ERROR

UNHANDLED REJECTION Encountered an error trying to infer a GraphQL type for: my index page___NODE. There is no corresponding node with the id field matching: "49592856-eefe-5c84-bdef-341d8f1c4206,c5636aa0-e388-50f3-a49b-3a88b632cd0e,268ea443-6fd9-5478-8f95-b7a0fb4f2a41,ffa853e7-692b-55c0-989a-ed9f51c287aa,db1d360f-f537-57ce-bd33-ae0923a676f4,7870ccfb-8a9b-5d23-b718-731685bfd7ed,3ccb8cb6-e215-53d4-954d-b21f5bb28f70,16bd91e0-daf5-5820-bace-3322ebcbe950".

Error: Invariant Violation: Encountered an error trying to infer a GraphQL type for: my index page___NODE. There is no c orresponding node with the id field matching: "49592856-eefe-5c84-bdef-341d8f1c4206,c5636aa0-e388-50f3-a49b-3a88b632cd0e,26 8ea443-6fd9-5478-8f95-b7a0fb4f2a41,ffa853e7-692b-55c0-989a-ed9f51c287aa,db1d360f-f537-57ce-bd33-ae0923a676f4,7870ccfb-8a9b-5d 23-b718-731685bfd7ed,3ccb8cb6-e215-53d4-954d-b21f5bb28f70,16bd91e0-daf5-5820-bace-3322ebcbe950".

  • invariant.js:40 invariant
    [public-site]/[invariant]/invariant.js:40:15

  • add-inferred-fields.js:262 getFieldConfigFromFieldNameConvention
    [public-site]/[gatsby]/dist/schema/infer/add-inferred-fields.js:262:3

  • add-inferred-fields.js:167 getFieldConfig
    [public-site]/[gatsby]/dist/schema/infer/add-inferred-fields.js:167:19

  • add-inferred-fields.js:91 Object.keys.forEach.key
    [public-site]/[gatsby]/dist/schema/infer/add-inferred-fields.js:91:25

  • Array.forEach

  • add-inferred-fields.js:78 addInferredFieldsImpl
    [public-site]/[gatsby]/dist/schema/infer/add-inferred-fields.js:78:28

  • add-inferred-fields.js:42 addInferredFields
    [public-site]/[gatsby]/dist/schema/infer/add-inferred-fields.js:42:3

  • index.js:102 addInferredType
    [public-site]/[gatsby]/dist/schema/infer/index.js:102:3

  • index.js:68 typesToInfer.map.typeComposer
    [public-site]/[gatsby]/dist/schema/infer/index.js:68:43

  • Array.map

  • index.js:68 addInferredTypes
    [public-site]/[gatsby]/dist/schema/infer/index.js:68:23

  • schema.js:161 updateSchemaComposer
    [public-site]/[gatsby]/dist/schema/schema.js:161:9

â ‹ building schema
â ‹ Add inferred types


### Environment

```  System:
    OS: macOS 10.14.6
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.12.0 - ~/.nodenv/versions/10.12.0/bin/node
    Yarn: 1.16.0 - /usr/local/bin/yarn
    npm: 6.6.0 - ~/.nodenv/versions/10.12.0/bin/npm
  Languages:
    Python: 3.6.4 - /Users/afehr/.pyenv/shims/python
  Browsers:
    Chrome: 76.0.3809.132
    Firefox: 64.0.2
    Safari: 12.1.2
  npmPackages:
    gatsby: ^2.8.5 => 2.15.14
    gatsby-cli: ^2.4.8 => 2.7.47
    gatsby-image: ^2.2.6 => 2.2.6
    gatsby-plugin-layout: ^1.0.6 => 1.0.9
    gatsby-plugin-postcss: ^2.0.1 => 2.0.1
    gatsby-plugin-react-helmet: ^3.0.1 => 3.1.0
    gatsby-plugin-react-next: ^1.0.11 => 1.0.11
    gatsby-plugin-rollbar: ^1.0.0 => 1.0.0
    gatsby-plugin-sass: ^2.0.3 => 2.0.4
    gatsby-plugin-sharp: ^2.0.32 => 2.0.32
    gatsby-plugin-sitemap: ^2.2.1 => 2.2.1
    gatsby-plugin-styled-components: ^3.0.4 => 3.0.4
    gatsby-source-contentful: ^2.1.35 => 2.1.35
    gatsby-source-filesystem: ^2.0.38 => 2.0.38
    gatsby-transformer-json: ^2.1.5 => 2.1.5
    gatsby-transformer-remark: ^2.3.12 => 2.6.1
    gatsby-transformer-sharp: ^2.1.17 => 2.1.17
stale? bug

Most helpful comment

In the end it was a rich text field that contained a reference to the page that contained the rich text field.

This issue can be closed

How did you ultimately solve this? I am running into a similar issue but I can't seem to figure out how to solve it. I unpublished the posts which were interlinked and my build succeeded.

All 5 comments

Hi, sorry to hear that you're running into issues. Did you maybe unpublish something, or have something crazy going on in Contentful? Maybe try cleaning Gatsby's cache by running gatsby clean.

Other than that we can help the best if you can reproduce the problem with a fresh contentful project :)

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

In the end it was a rich text field that contained a reference to the page that contained the rich text field.

This issue can be closed

In the end it was a rich text field that contained a reference to the page that contained the rich text field.

This issue can be closed

How did you ultimately solve this? I am running into a similar issue but I can't seem to figure out how to solve it. I unpublished the posts which were interlinked and my build succeeded.

For anyone searching: I used gatsby clean as @LekoArts suggested.

The problem was caused by unpublishing and deleting content in Contentful. It seems the local cache expected it to be there and threw the error.

My error messages were:

UNHANDLED REJECTION Encountered an error trying to infer a GraphQL type for:blog post___NODE. There is no corresponding node with theidfield matching: "c3f2909f-32ef-51f5-aa5a-7a366a70559d,0437e57f-0cf8-549c-bb15-303b6b5c58b7,759d32fd-c066-5797-91cd-3102563e39a8,950df4b4-82c9-59da-a118-d1586acc0221,884ca999-f76c-5c56-9d38-b9ecf038172a,e9b6d685-91c9-59ea-9887-61f6ed380f64".

Error: Invariant Violation: Encountered an error trying to infer a GraphQL type for:blog post___NODE. There is no corresponding node with theidfield matching: "c3f2909f-32e f-51f5-aa5a-7a366a70559d,0437e57f-0cf8-549c-bb15-303b6b5c58b7,759d32fd-c066-5797-91cd-3102563e39a8,950df4b4-82c9-59da-a118-d1586acc0221,884ca999-f76c-5c56-9d38-b9ecf038172a,e9b6d6 85-91c9-59ea-9887-61f6ed380f64".

Was this page helpful?
0 / 5 - 0 ratings

Related issues

theduke picture theduke  Â·  3Comments

ghost picture ghost  Â·  3Comments

mikestopcontinues picture mikestopcontinues  Â·  3Comments

ferMartz picture ferMartz  Â·  3Comments

rossPatton picture rossPatton  Â·  3Comments