-
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 Rich Text Invalid string length #21957
Comments
I am also facing the exact issue |
Hi @nadiavanleur ! Sorry to hear you're running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it. You can probably use contentful starter to prepare a reproduction site and contentful-export tool to fetch the content that produces this error. If you're up for it, we'd very much appreciate if you could provide a minimal reproduction and we'll be able to take another look. Thanks for using Gatsby! 💜 |
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. Thanks for being a part of the Gatsby community! 💪💜 |
I am running into a similar issue. My build fails with a function prepareRichTextNode(node, key, content, createNodeId) {
const str = stringify(content); The issue is that the contentful sdk link resolver creates a nested traversable object. As all links are resolved, an RTE link to a piece of content with multiple links could lead to the resulting object containing the entire site... I have confirmed this is the issue by disabling the link resolver on the contentful client. As for how to resolve this issue... I'm not sure that I see a simple way of doing it. Ultimately, the implementation of outputting the RTE content as JSON is simply not compatible with the idea of being able to retrieve fields of entries linked in the RTE. Either the gql content types for RTE content need to be defined so that RTEs can leverage gql, or the JSON content needs to be trimmed somehow... Unfortunately due to the nature of the issue, creating a minimal reproduction is both complicated (the issue only occurs when you have a lot of content) and unreliable (an out of memory error depends on the amount of memory available to the environment). |
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. Thanks for being a part of the Gatsby community! 💪💜 |
Hey again! It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Thanks again for being part of the Gatsby community! 💪💜 |
Description
TL;DR
I added a lot of content and started to use Contentful's links to entries when I started getting this error:
My project was going absolutely fine until I added a lot more content to Contentful. I also started to use @contentful/rich-text-react-renderer, which I think might be relevant. When I tried to run
npm run dev
ornpm run build
after adding the content I got aJavaScript heap out of memory
error. I fixed this by usingexport NODE_OPTIONS=--max_old_space_size=4096
in the command line. Then my current problem occured.Things I have tried to fix this:
exports.createSchemaCustomization = ({...})
from gatsby-node.jsUPDATE
I added a bunch of
console.log(...)
s to the function the error says theInvalid string length
message comes from (gatsby-source-contentful/normalize.js > createNodesForContentType()
) and have found the error keeps coming back when looping through entryItemFields. The build stops working specifically when afieldType
isRichText
. TheInvalid string length
error then gets thrown. However, it doesn't always do this, the first couple of times there is no error and it just continues.The program seems to stop working on line
473: const richTextNode = prepareRichTextNode(entryNode, entryItemFieldKey, entryItemFields[entryItemFieldKey], createNodeId);
ofgatsby-source-contentful/normalize.js
My guess is some of the serialized rich text objects are too large to be handled.
UPDATE 2
I removed all Rich Text fields from my Contentful CMS and the problem seems to be gone. Therefore my best guess is still some of the serialized rich text objects are too large to be handled.
Steps to reproduce
exports.createPages({...})
andexports.createSchemaCustomization = ({...})
Expected result
I expected my build to run as usual.
Actual result
Environment
The text was updated successfully, but these errors were encountered: