contentful.js: "Maximum call stack size exceeded" on circular-references

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

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 18 (2 by maintainers)

Commits related to this issue

Most upvoted comments

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!

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

Experiencing the same issue. A thing that is related to a thing that is related back to it. Not an uncommon scenario. Using 7.14.8. Is there any known workaround?

this keeps happening. Same case of blogpost linking to 3 blogposts. If it links to itself RangeError: Maximum call stack size exceeded shows up

I am still experiencing this issue with the new version, but I think my usecase is different.

I have a content-type blogPost, which can have 3 related blogPosts (references, many). Simplified, something like this happens:

blogPost A, has blogPost X, Y and Z as related blogPosts in turn, blogPost X has blogPost A as related blogPost

So the circular dependency lies one level deeper.

With resolveLinks: false it wont fail, but then I will still need manually resolve the links. With resolveLinks: true and include: 1 it will still throw RangeError: Maximum call stack size exceeded