Heroku server crashes with “JavaScript heap out of memory” when deploying ‘react-admin’ app

Contacted heroku support, here I solved the issue:

The error has occurred because the node can only address 1.5GB of memory before hitting the JavaScript heap out of memory error, a default limit that it inherits from the V8 engine. We tweak this default setting on Heroku through the NODE_OPTIONS env var so that the process can address all of the memory available: https://github.com/heroku/heroku-buildpack-nodejs/blob/master/lib/environment.sh#L29-L33

One option would be to specifically call –max_old_space_size=2560 when invoking node to see if that helps alleviate the issue. You can pass that option to Node via environment variable by running the following:

$ heroku config:set NODE_OPTIONS="--max_old_space_size=2560" -a [app_name]

Also adjust the build script to be:

"scripts": {
    "start": "node --max_old_space_size=2560 node_modules/.bin/react-scripts start",
    "build": "node --max_old_space_size=2560 node_modules/.bin/react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  }

Though not really sure build and start scripts change impacting.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)