-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gatsby-source-contentful: Maximum call stack size exceeded #11364
Comments
https://www.gatsbyjs.org/packages/gatsby-source-contentful/?=contentful Not sure if this would help, but try to disconnect one of your reference. |
@karenhou It's not reference fields that's the problem. It makes sense to have references one way. What I'm talking about is the Rich text field which has Entry hyperlink support. If you want to create a Say you have a 3 part article that would link to each other in the beginning. That would never work right now if you're not fine hardcoding the links. |
My best guess is some recursive handling of references is exploding the call stack because of the lack of an exit case that covers this maybe? @marcneander Can you try to create a minimal reproduction repo for this (with a contentful instance setup to break it) and link to it? That'll help us debug this faster |
I've been looking into this issue because we're also experiencing it. I'm not very familiar with the contentful source plugin codebase but the first impression is that the logic in place to avoid circular references only accounts for field types which are not richText. The latter is a lot more complex to analyze because it can contain a "link" to another entry in deeply nested places. I think that the logic to handle this should live in the At the current time, two entries cross-referencing each other via hyperlinks inside a richText field lead to infinite recursion. This is a perfectly valid use case, of a series of articles referencing each other at the top of the article content for instance, and @marcneander repro is a perfect one. |
@sidharthachatterjee Thanks for your work on this. Would just like to add my upvote to this issue - we've encountered the exact same scenario, and I would second @simoneb's comments about this being a very valid use-case and @marcneander's repro an accurate reduced test-case of our situation. We've got a very urgent situation on our hands at the moment - do you think it likely you'll be looking at this soon? Otherwise we will look at a PR of some sort. Thanks again. |
Hi @marcneander, given the lack of support around here we've worked around the issue by forking the gastby repo, changing the Because it was really hard to figure out how to handle rich text nodes with links to other contentful entries, we've come up with a workaround which consists in the plugin accepting an array of whitelist field names to include when processing rich text field nodes. All other fields are omitted. For the lack of a better and generic solution, this basically shifts the responsibility of which fields won't cause circular references on the shoulders of developers. For instance, we use the
So, I configure our custom You can find our fork here. The plugin is published as @nearform/gatsby-source-contentful. Hope it helps! |
@simoneb TY for your fork. This fixed the issue for me as well. It's pretty easy to get into this kind of reference, so although it's not an optimal fix I really appreciate you publishing your fork. |
@snide you're welcome! |
I'd also like to upvote this, this is currently making internal links impossible to use in the RichText. If the reference contains any link back to the content at any level this causes the stack size explosion, which is impossible to manage or restrict. |
@toby-bushell as unappealing a solution as it may sound, have you tried the fork I mentioned here? That's the solution we are applying for now. |
Hi @simoneb, am I right in thinking that the workaround is to skip trying to resolve internal links? And explicitly list the embed types to resolve in Rich Text? |
@toby-bushell not entirely. If you list only the fields that you need when processing your rich text, they will be resolved. The rest you will not need can safely not include in the whitelist so it doesn't cause issues. |
@simoneb thanks for this and the fork, It looks like a good failsafe option, that we may well use. We do however want to be able to link to other references safely within RichText and are keen on a permanent solution, as this is a very big feature of contentful. Even an understanding of the roadmap for this so we can make a call on how much time to dedicate to alternatives. |
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! Thanks for being a part of the Gatsby community! 💪💜 |
Spooky quiet indeed. But not ready to be closed |
Having the same issue, also found a mention of the same problem here contentful/rich-text#53 (issue was closed but it seems to me that the problem is still present). Cross referencing entries is a quite natural thing (inline link from one page to another for example, much better to be able to use a reference rather than a hardcoded string) As a temporary workaround I used the forked version and queried
Downside is the resulting data has a different structure so once it's fixed I'll have to refactor all field access. |
Hey @simoneb, |
@Khaledgarbaya because the fix is not generic enough in my opinion, it's more of a workaround. |
There is a repro in the form of an e2e test in this PR: #15358 It's not isolated from contentful, but it should demonstrate the issue still. |
Ok. Can repro. On it. |
@cameron-martin Thank you. I was able to add a repro to the tests that caught this stack overflow and able to prevent the stack overflow. Please report back after testing with #20039 . |
@cameron-martin This repro was fixed in #20039 which has been published. Please check whether this works for you. I'm going to close this for now. If anyone has related problems feel free to reopen. Or a new issue and tag me. Thanks! |
🚨 I've created a minimal reproduction of this issue! 🚨 This appears to still be a problem on the latest version of Gatsby, even after #20039 was merged. Here is the repo: https://github.com/jessepinho/gatsby-contentful-infinite-loop-repro Here's the Contentful Discovery app with all the data (note that a bug in the app prevents it from showing article records): https://discovery.contentful.com/entries/by-content-type?delivery_access_token=04QAYaRsr548atM4KwInDCWk8v84agx0uS7r8LrQutk&preview=false&preview_access_token=&space_id=j66qheg22uli @pvdz could you please reopen this issue? (I don't have rights to.) |
Great, thank you! |
Confirmed. Looking into a fix now. |
The fix (which at least resolves your repro) is in #20674 Follow that to see when it gets merged and to see what version it gets released in. |
@pvdz WOW that was fast, thank you! When I get a chance, I'll try it with my real-life repo and see if it fixes the issue. |
With #20674 being merged this repro has been fixed. It should be published on the next patch bump (should be posted on PR). Please feel free to reopen (with repro..) if you're still having issues after that. |
I can confirm that this fix (released with v 2.7.8) solves my problem 👍 Thanks a lot! edit: I meant version number |
I just upgraded and am still experiencing the problem in my own repo. @ma-pe what library do you have v2.7.8 of? There is no |
@jessepinho are you saying the repro you posted is still having this problem with the above fix in place? I couldn't repro it anymore when it landed. But please let me know if you can repro it when all deps are up to date (it may help to just delete the |
I assumed he meant 2.1.78. I also continued to experience the problem with v2.1.78 so I continued to use a work-around with legacy versions. |
@vpreponen The current published version is 2.1.85, can you check if you're still experiencing it with that version? (Is there anything blocking you from upgrading the patch bump?) |
@pvdz not the repro I posted, but a separate repo that I was trying to reproduce with that minimal repro I posted. Apparently it was a little too minimal 😆 Will look into this further. And yeah I used |
@jessepinho ok, if you manage to get another repro repo or test case please share it and I'll have a look and try to fix it :) |
Deleting lock files and node_modules plus updating to gatsby v2.19.16 and gatsby-source-contentful v2.1.85 fixes the issue for me. |
I have one here: #27515 |
im still having problems... |
…#19802) * fix(gatsby): do not cause stack overflow over circular refs This allows nodes to have a circular dependency without causing stack overflow exceptions when traversing the graph. Fixes gatsbyjs#11364 (hopefully). Will have to confirm this after publishing an update. Causes somewhere between 0 and 1% perf regression for our 25k page benchmark site. * Use actual `if` for conditionals * Only add data to the path when actually an object
Not sure if this is a bug or not. And unfortunately I don't really have much time this week to investigate. But I thought I might as well put this up here.
I'm using the
gatsby-source-contentful
plugin. In my contentful content model I'm having two content types, both with the new Richtext editor. Problems occurs when I have entry links to each other.To be more clear. Say I have two pages, home and about. If I link from home -> about and from about -> home inside the Richtext editor I get this error.
Like I said before. Not sure if this is a bug.
Here's a callstack https://pastebin.com/fD676e6j
Environment (if relevant)
gatsby-config.js
:The text was updated successfully, but these errors were encountered: