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.

"Maximum call stack size exceeded" on circular-references

See original GitHub issue
  • Node Version: v8.0.0
  • Npm Version: v5.4.2
  • Platform: Darwin Kernel Version 17.0.0: Thu Aug 24 21:48:19 PDT 2017; root:xnu-4570.1.46~2/RELEASE_X86_64 x86_64 (its a macbook pro on osx 10.13)
  • Package Version: v5.0.1

Our contentpull package (https://github.com/remedyhealth/contentpull) wraps this package to simplify some of our conventional queries. We were alerted that our tests were failing when upgrading to your latest (v5.0.1).

It was discovered after using this package on its own that our test data was failing due to a maximum call stack issue (as seen below)

RangeError: Maximum call stack size exceeded
      at memoized (node_modules/contentful/dist/webpack:/node_modules/lodash/memoize.js:54:1)
      at Object.get (node_modules/contentful/dist/webpack:/mixins/link-getters.js:61:20)
      at node_modules/contentful/dist/webpack:/mixins/link-getters.js:42:21
      ...

Our failure is a circular referential test. While this is a bit odd we do have this circumstance in production (related categories reference each other).

Our test is simply to make sure those references work (which worked fine in previous versions):

it('should be able to parse a circularly referenced object', () => {
  return client.getEntries({'sys.id': entryId}).then(entries => {
  let nested = entries.items[0].fields.ref.fieds.ref.fields.ref.fields.ref.fields.ref // you get the idea...
  nested.sys.id.should.equal(entryId)
})

Our test data is a single reference to itself on the field ref. Below you will find the sample data:

{
  sys: {
    space: {
      sys: {
        type: 'Link',
        linkType: 'Space',
        id: 'space1'
      }
    },
    id: 'entry1',
    type: 'Entry',
    createdAt: '2016-04-06T15:43:38.945Z',
    updatedAt: '2016-06-08T14:52:24.824Z',
    revision: 4,
    contentType: {
      sys: {
        type: 'Link',
        linkType: 'ContentType',
        id: 'contentType1'
      }
    },
    locale: 'en-US'
  },
  fields: {
    title: 'TestEntry',
    ref: {
      sys: {
        type: 'Link',
        linkType: 'Entry',
        id: 'entry1'
      }
    }
  }
}

Please let us know if there is anything else we can assist with in resolving this issue.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
mrsteelecommented, Jan 9, 2018

Thanks @axe312ger! I can confirm installing this locally resolved our maximum call stack issue!

Thanks so much and we will be looking forward to the next official release of this!

1reaction
axe312gercommented, Dec 23, 2020

@matthew-contentful @TimBeyer I guess you should consider reopening this as people seem to still run into this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Maximum call stack size exceeded - Object Initializer with ...
Case 1 this === global. Here this is the global javascript context. Typically is huge and contains many circular references.
Read more >
circular references - error: "Maximum call stack size exceeded ...
Circular references causes error: "Maximum call stack size exceeded". var b = {. prop_b: "bbbb". }; var a = {. prop_a: "aaaa", b:...
Read more >
Maximum call stack error occurs when you edit the row.
DataGrid - Maximum call stack size error occurs when circular reference is set as a field and validation rule is applied in editing...
Read more >
RangeError: Maximum call stack size exceeded at Observable ...
Generally , the reason for exceeding maximum call stack when stringifying is because you have circular references ( or loops ). https://developer.mozilla.org/en ...
Read more >
Circular references in React prop data causes stack overflow ...
If a data structure with a circular reference is supplied a prop to a React component, Storybook will error with a Maximum call...
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