Unverified Commit 9fa6f571 authored by Jeremy Morrell's avatar Jeremy Morrell Committed by GitHub

Increase Node memory default during builds (#561)

We've seen an increasing failures due to frontend build exceeding Node
default 1.5GB memory limit during build. Heroku runs these builds on
machines with 2.5GB of memory. This increases the default limit for
Node 8 and above by passing commands via `NODE_OPTIONS` during build
if the user has not set this manually
parent a8372ab8
......@@ -85,6 +85,7 @@ mkdir -p "$BUILD_DIR/.heroku/node/"
cd $BUILD_DIR
create_env # can't pipe the whole thing because piping causes subshells, preventing exports
list_node_config | output "$LOG_FILE"
create_build_env
### Configure package manager cache directories
[ ! "$YARN_CACHE_FOLDER" ] && export YARN_CACHE_FOLDER=$(mktemp -d -t yarncache.XXXXX)
......
......@@ -22,6 +22,14 @@ create_default_env() {
export NODE_VERBOSE=${NODE_VERBOSE:-false}
}
create_build_env() {
# if the user hasn't set NODE_OPTIONS, increase the default amount of space
# that a node process can address to match that of the build dynos (2.5GB)
if [[ -z $NODE_OPTIONS ]]; then
export NODE_OPTIONS="--max_old_space_size=2560"
fi
}
list_node_config() {
echo ""
printenv | grep ^NPM_CONFIG_ || true
......
A fake README, to keep npm from polluting stderr.
\ No newline at end of file
{
"name": "node-buildpack-test-app",
"version": "0.0.1",
"description": "node buildpack integration test app",
"repository" : {
"type" : "git",
"url" : "http://github.com/example/example.git"
},
"dependencies": {
"hashish": "*"
},
"engines": {
"node": "8.x"
},
"scripts": {
"start": "node foo.js",
"heroku-postbuild": "echo NODE_OPTIONS=$NODE_OPTIONS"
}
}
......@@ -45,6 +45,18 @@ testNodeModulesCached() {
assertCapturedSuccess
}
testSetBuildEnv() {
cache=$(mktmpdir)
env_dir=$(mktmpdir)
compile "print-node-options"
assertCaptured "NODE_OPTIONS=--max_old_space_size=2560"
echo "--max_old_space_size=1234" > $env_dir/NODE_OPTIONS
compile "print-node-options" $cache $env_dir
assertCaptured "NODE_OPTIONS=--max_old_space_size=1234"
}
testYarn() {
compile "yarn"
assertCaptured "installing yarn"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment