Skip to content
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

Large amount of locales/data enabled in contentful case "JavaScript heap out of memory" #12938

Closed
stoltzrobin opened this issue Mar 29, 2019 · 4 comments
Assignees
Labels
stale? Issue that may be closed soon due to the original author not responding any more.

Comments

@stoltzrobin
Copy link
Contributor

stoltzrobin commented Mar 29, 2019

Summary

Enable the user to filter out unnecessary locales from Contentful.

Basic example

 {
      resolve: `gatsby-source-contentful`,
      options: {
        [... other settings needed]
        localeFilter: locale =>
          locale.code === ACTIVE_LOCALE || locale.code === DEFAULT_LOCALE,
      },
},

By passing a filter function we can limit the amount of nodes created in graphQL.

Motivation

In our case we have over 50 locales in Contentful and over 2500 entries (this numbers are increasing every week as well). This create a lot of nodes in the Contentful plugin, which case the JS VM instance to run our of memory. In our application we only build one locale per build (to improve build speed) and all other nodes from different locales an useless and not needed.

In our application it reduces the JS VM runtime memory around 80%.

@wardpeet
Copy link
Contributor

Thanks for filling an issue and fixing it yourself! 💪 that's just bonkers!

Could you provide a bit more info about where it fails exactly? Just making sure it's not a known issue with saving redux state as we have an issue open for sites with lots of pages.

#12343

Would be handy if it's the same issue that you can comment in that thread as well.

@thibautRe
Copy link
Contributor

I can provide more info (Robin and I work together, and he's on holiday as of now I'm super jealous btw! :D so he might not be able to answer until he's back).

The errors we started to experience randomly are memory issues (not speed), and would lead to our JS runtime running out of memory and throwing a wonderful C++ error. Using --max-old-space-size was helping us for local development but were not fixing the issue for Cloud builds - where the machines have limited amount of memory.

The OutOfMemoryError would get thrown randomly - sometimes not at all, and at random times... Most of the time the error would happen between the node sourcing and the graphql schema generation steps. I don't remember us seeing the error during the graphql queries step, or HTML generation step.

Also, we tried using the lokijs feature flag but that didn't help.

@gatsbot
Copy link

gatsbot bot commented Apr 19, 2019

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! 💪💜

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Apr 19, 2019
@thibautRe
Copy link
Contributor

Fixed in #12939

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more.
Projects
None yet
Development

No branches or pull requests

4 participants