Razzle: JavaScript heap out of memory

Created on 2 May 2019  路  6Comments  路  Source: jaredpalmer/razzle

I tried to convert a medium sized existing Razzle project to Typescript. It should be all setup correctly because when I remove all but one imports from my App.tsx it does compile and show the home view.

However, when I add back all the imports (via loadable-components), then trying to run yarn start results in this:

<--- Last few GCs --->

[47780:0x103a7a000]    44764 ms: Mark-sweep 3965.8 (4033.5) -> 3965.5 (4031.5) MB, 234.7 / 0.0 ms  (average mu = 0.168,
 current mu = 0.073) allocation failure GC in old space requested
[47780:0x103a7a000]    45012 ms: Mark-sweep 3965.5 (4031.5) -> 3965.1 (4034.5) MB, 247.5 / 0.0 ms  (average mu = 0.088,
 current mu = 0.000) allocation failure GC in old space requested


<--- JS stacktrace --->

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

[...]

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x100033aa9 node::Abort() [/usr/local/Cellar/node/10.6.0/bin/node]

I have browsed the web for 2 hours now but no solution seems to be working. Has anyone encountered this? I should say that all files in this project are still JS files, I have configured Typescript so that it runs alongside babel. Could this be an issue? Should I convert the entire application to TSX files to get rid of this problem?

Most helpful comment

I managed to resolve this by "build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 razzle build",

Give that a go. Put the cross-env NODE_OPTIONS=--max_old_space_size=8192 in front of whatever command is leading to your outcome

All 6 comments

Running into similar issues on the production build in a monrepo. Jared just released a project with a out of the box typescript setup. Perhaps that will help you.

I managed to resolve this by "build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 razzle build",

Give that a go. Put the cross-env NODE_OPTIONS=--max_old_space_size=8192 in front of whatever command is leading to your outcome

I already tried 8129 yesterday with no luck.

Running into similar issues on the production build in a monrepo. Jared just released a project with a out of the box typescript setup. Perhaps that will help you.

@mschipperheyn what project are you referring to?

@mschipperheyn whoa! The cross-env thing actually works! Thank you SO much!

What I did yesterday was to change the options of the typescipt plugin in razzle.config.js so that it says Using 1 worker with 8192MB memory limit but it seems that that was not enough.

Aha!

I disabled devtool in razzle.config.js like this:

  modify: (config, { target, dev }, webpack) => {
    if (dev) {
      config.devtool = 'none'
    }

I never need sourcemaps during local development anyways. Now I get away with 4GB and yarn start compiles twice as fast:

# package.json "scripts": { "start": "cross-env NODE_OPTIONS=--max_old_space_size=4096 razzle start", "build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 razzle build",

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GouthamKD picture GouthamKD  路  3Comments

mhuggins picture mhuggins  路  3Comments

dizzyn picture dizzyn  路  3Comments

corydeppen picture corydeppen  路  3Comments

knipferrc picture knipferrc  路  5Comments