From 62127760f3e7c76670b8392cec57f6cc8d9c53db Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Mon, 16 Jan 2023 19:16:23 -0800 Subject: [PATCH] chore: ci --- .circleci/config.yml | 7 ++++--- .env-cmdrc.js | 20 ++++++-------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a06f187e4..7b86bd109 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -287,9 +287,10 @@ jobs: environment: GENERATE_SOURCEMAP: 'false' SKIP_PREFLIGHT_CHECK: 'true' - # Can increase if experiencing out-of-memory issues - https://circleci.com/docs/2.0/configuration-reference/#resourceclass - # NOTE - memory available to node is automatically configured in .env-cmdrc - resource_class: medium + NODE_OPTIONS: '--max-old-space-size=5632' + # If experiencing out-of-memory issues can increase resource_class below and max space size above + # https://circleci.com/docs/2.0/configuration-reference/#resourceclass + resource_class: medium+ steps: # whilst checkout-install could be persisted from previous step, that is less efficient than just using caching - checkout diff --git a/.env-cmdrc.js b/.env-cmdrc.js index 3e931a7d3..93f01c335 100644 --- a/.env-cmdrc.js +++ b/.env-cmdrc.js @@ -28,27 +28,19 @@ function getNodeOptions() { let NODE_OPTIONS = process.env.NODE_OPTIONS || '' - // fix out-of-memory issues - dynamically set max available memory based on machine - // use up to 4GB locally, and 90 % machine max when running on CI, loosely based on - // https://github.com/cloudfoundry/nodejs-buildpack/pull/82 + // fix out-of-memory issues - default to 4GB but allow override from CI + // NOTE - would like to auto-calculate but does not support CI (https://github.com/nodejs/node/issues/27170) if (!NODE_OPTIONS.includes('--max-old-space-size')) { - let maxSize = 4096 - if (process.env.CI) { - const totalMem = require('os').totalmem() / (1024 * 1024) - maxSize = Math.floor(totalMem * 0.9) - } - NODE_OPTIONS += ` --max-old-space-size=${maxSize}` + NODE_OPTIONS += ` --max-old-space-size=4096` } if (NODE_VERSION > '17') { // fix https://github.com/facebook/create-react-app/issues/11708 // https://github.com/facebook/create-react-app/issues/12431 NODE_OPTIONS += ' --openssl-legacy-provider --no-experimental-fetch' } - console.log(process.env) - if (process.env.CI) { - console.log(NODE_OPTIONS) - process.exit(1) - } + if (process.env.CI) { + console.log('NODE_OPTIONS', NODE_OPTIONS, '\n') + } return NODE_OPTIONS.trim() }