From af941c14603bc1ee6e53112c0745053884c17383 Mon Sep 17 00:00:00 2001 From: henrytk Date: Wed, 4 Jul 2018 10:23:28 +0100 Subject: [PATCH] Prevent webpack from hanging during staging Staging was hanging indefinitely when it started optimizing assets (part of the `npm run build` postinstall script). I didn't investigate fully, but it seems to be related to Node's poor grasp of system resources[1,2,3]. One suspect was identified in the build output: ``` > npm run build (node:46) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added. Use emitter.setMaxListeners() to increase limit ``` [1] https://github.com/webpack/webpack/issues/2012#issuecomment-337263767 [2] https://github.com/webpack/webpack/issues/4558 [3] https://github.com/webpack-contrib/sass-loader/issues/100 Signed-off-by: Lee Porte --- manifest.yml | 2 +- package.json | 21 ++++++++------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/manifest.yml b/manifest.yml index 7ea36268fb..34bbcd184b 100644 --- a/manifest.yml +++ b/manifest.yml @@ -2,7 +2,7 @@ applications: - name: hackmd instances: 1 - memory: 2G + memory: 6G buildpack: nodejs_buildpack env: PGSSLMODE: require diff --git a/package.json b/package.json index 10c09d8aeb..f459410ac9 100644 --- a/package.json +++ b/package.json @@ -15,19 +15,14 @@ "license": "AGPL-3.0", "main": "app.js", "scripts": { - "build": "webpack --config webpack.prod.js --display errors-only -p", - "dev": "webpack --config webpack.dev.js --progress --colors --watch", - "doctoc": "doctoc --title='# Table of Contents' README.md", - "lint": "standard", - "jsonlint": "find . -type f -not -ipath \"./node_modules/*\" \\( -name \"*.json\" -o -name \"*.json.*\" \\) | xargs -n 1 -I{} -- bash -c 'echo {}; jq . {} > /dev/null;'", - "start": "sequelize db:migrate && node app.js", - "mocha": "mocha --require intelli-espower-loader --exit ./test --recursive", - "mocha:ci": "mocha --no-color -R dot --require intelli-espower-loader --exit ./test --recursive", - "coverage": "nyc mocha --require intelli-espower-loader --exit --recursive ./test", - "coverage:ci": "nyc mocha --no-color -R dot --require intelli-espower-loader --exit --recursive ./test", - "test": "npm run-script lint && npm run-script jsonlint && npm run-script coverage", - "test:ci": "npm run-script lint && npm run-script jsonlint && npm run-script coverage:ci", - "postinstall": "npm run build" + "test": "npm run-script standard && npm run-script jsonlint", + "jsonlint": "find . -not -path './node_modules/*' -type f -name '*.json' -o -type f -name '*.json.example' | while read json; do echo $json ; jq . $json; done", + "standard": "node ./node_modules/standard/bin/cmd.js", + "dev": "webpack --config webpack.config.js --progress --colors --watch", + "build": "node --max-old-space-size=6144 node_modules/webpack/bin/webpack.js --config webpack.prod.js --progress --colors --bail", + "postinstall": "npm run build", + "start": "node app.js", + "doctoc": "doctoc --title='# Table of Contents' README.md" }, "dependencies": { "@hackmd/codemirror": "~5.46.2",