gatsby: 1.9.9 -> 1.9.100, now 'Javascript heap out of memory'

I’ve been putting off upgrading Gatsby b/c I kept getting a ‘heap out of memory’ error, but I decided today to track it down.

One of my source-filesystem sources creates 656 nodes (of type consultant) from a JSON. the JSON is about 800kb.

This is the output from running yarn develop:

$ yarn develop
yarn run v1.2.1
$ bnr develop
running better-npm-run in /mnt/c/Users/brand/code/admitbrain
Executing script: develop

to be executed: gatsby develop --max-old-space-size=8192
running better-npm-run in /mnt/c/Users/brand/code/admitbrain

success delete html files from previous builds — 0.558 s
success open and validate gatsby-config.js — 0.005 s
success copy gatsby files — 0.178 s
success onPreBootstrap — 0.047 s
⠈ source and transform nodesStarting to fetch data from Contentful
Fetching default locale
⠂ source and transform nodesdefault local is : en-US
⢀ source and transform nodescontentTypes fetched 8
Updated entries  0
Deleted entries  0
Updated assets  0
Deleted assets  0
Fetch Contentful data: 366.713ms
success source and transform nodes — 7.873 s
success building schema — 1.244 s
success createLayouts — 0.050 s
⠠ createPagesStarting: Blog pages.
Finished: Created 11 blog pages.
Starting: Agency pages.
⠠ createPagesFinished: Created 68 Agency pages.
Starting: School pages.
⠐ createPagesFinished: Created 10 School pages.
Starting: Consultant pages.
⠂ createPagesFinished: Created 656 Consultant pages.
success createPages — 16.948 s
success createPagesStatefully — 0.120 s
success onPreExtractQueries — 0.014 s
success update schema — 6.081 s
success extract queries from components — 0.265 s
⠁
<--- Last few GCs --->

[11566:0x37ab5d0]    73868 ms: Mark-sweep 1416.3 (1495.9) -> 1416.3 (1479.9) MB, 915.0 / 0.0 ms  (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 915 ms) last resort
[11566:0x37ab5d0]    74780 ms: Mark-sweep 1416.3 (1479.9) -> 1416.3 (1479.9) MB, 912.6 / 0.0 ms  last resort


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x196898628799 <JSObject>
    0: builtin exit frame: captureStackTrace(aka captureStackTrace)(this=0x393b29c02311 <undefined>,0x2f691ed37cd1 <JSFunction CapturedTrace (sfi = 0x25975f15c491)>,0x328575c09329 <CapturedTrace map = 0x38644cc40001>)

    1: _then [/mnt/c/Users/brand/code/admitbrain/node_modules/bluebird/js/release/promise.js:~219] [pc=0x2c92629e6e1f](this=0x3470fb292b09 <Promise map = 0x38644cc400b1>,didFulfil...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [node]
 2: 0x1356bec [node]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
 5: v8::internal::Factory::NewRawOneByteString(int, v8::internal::PretenureFlag) [node]
 6: v8::internal::Factory::NewStringFromOneByte(v8::internal::Vector<unsigned char const>, v8::internal::PretenureFlag) [node]
 7: v8::internal::Factory::NumberToString(v8::internal::Handle<v8::internal::Object>, bool) [node]
 8: 0x1088f51 [node]
 9: v8::internal::JSStackFrame::ToString() [node]
10: v8::internal::ErrorUtils::FormatStackTrace(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSObject>, v8::internal::Handle<v8::internal::Object>) [node]
11: v8::internal::Builtin_ErrorCaptureStackTrace(int, v8::internal::Object**, v8::internal::Isolate*) [node]
12: 0x2c926270449d
Aborted (core dumped)
error Command failed with exit code 134.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This happens both with and without the --max-old-space-size=8192 flag.

However, when I remove the pageQuery export from my consultant template, the build completes fine.

I’ve tried pulling fields from the pageQuery to see if it was just one query that was doing it, but even with a trivial 1-field query, the crash happens.

I can’t imagine my 658 nodes is more than Gatsby can handle, but OTOH everything worked fine pre-upgrade (and still does on my Master branch), so just trying to narrow-down cause here.

Here’s my versions before the upgrade:

 "gatsby": "^1.9.9",
        "gatsby-image": "^1.0.16",
        "gatsby-link": "^1.6.13",
        "gatsby-plugin-catch-links": "^1.0.6",
        "gatsby-plugin-manifest": "^1.0.7",
        "gatsby-plugin-offline": "^1.0.7",
        "gatsby-plugin-react-helmet": "^1.0.4",
        "gatsby-plugin-resolve-src": "^1.0.0",
        "gatsby-plugin-sharp": "^1.6.3",
        "gatsby-plugin-sitemap": "^1.2.5",
        "gatsby-plugin-typography": "^1.7.7",
        "gatsby-remark-autolink-headers": "^1.4.7",
        "gatsby-remark-external-links": "^0.0.3",
        "gatsby-remark-images": "^1.5.6",
        "gatsby-remark-smartypants": "^1.4.7",
        "gatsby-source-contentful": "^1.3.7",
        "gatsby-source-filesystem": "1.0.1",
        "gatsby-source-google-sheets": "^1.0.5",
        "gatsby-transformer-json": "^1.0.4",
        "gatsby-transformer-remark": "^1.7.4",
        "gatsby-transformer-sharp": "^1.6.2",

And here’s my versions post-upgrade:

"gatsby": "^1.9.100",
        "gatsby-image": "^1.0.16",
        "gatsby-link": "^1.6.13",
        "gatsby-plugin-catch-links": "^1.0.6",
        "gatsby-plugin-manifest": "^1.0.7",
        "gatsby-plugin-nprogress": "^1.0.7",
        "gatsby-plugin-offline": "^1.0.7",
        "gatsby-plugin-react-helmet": "^1.0.4",
        "gatsby-plugin-resolve-src": "^1.0.0",
        "gatsby-plugin-sharp": "^1.6.19",
        "gatsby-plugin-sitemap": "^1.2.5",
        "gatsby-plugin-typography": "^1.7.7",
        "gatsby-remark-autolink-headers": "^1.4.7",
        "gatsby-remark-external-links": "^0.0.3",
        "gatsby-remark-images": "^1.5.6",
        "gatsby-remark-smartypants": "^1.4.7",
        "gatsby-source-contentful": "^1.3.19",
        "gatsby-source-filesystem": "^1.5.7",
        "gatsby-source-google-sheets": "^1.0.5",
        "gatsby-transformer-json": "^1.0.11",
        "gatsby-transformer-remark": "^1.7.4",
        "gatsby-transformer-sharp": "^1.6.13",

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 5
  • Comments: 17 (9 by maintainers)

Most upvoted comments

For anyone that may still be having issues, don’t forget to try removing any lock files (package-lock.json or yarn.lock) and doing a fresh install with the most up to date version of gatsby. I spent a good amount of time trying to figure out why I was still getting this error even after updating gatsby and it turned out to be a stale lock file.

#2969 is out + a handful of other related performance PRs!

Would love to hear from y’all if things work better now. Sorry about the troubles you had in the past.