From 3473c4d5376319274bdfe0ae176e66ff9a592d4a Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 28 Feb 2022 17:59:07 +0100 Subject: [PATCH] fix(ng-dev): limit the amount of CPUs used by workers Some environments, like CircleCI which use Docker report a number of CPUs by the host and not the count of available. This causes the task to be killed when formatting a large number of files due lack of resources. https://app.circleci.com/pipelines/github/angular/angular-cli/20921/workflows/1f32e2ff-e726-41bc-a47c-9926f8b02f1d/jobs/290488 --- ng-dev/format/run-commands-parallel.ts | 5 ++++- tools/local-actions/changelog/main.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ng-dev/format/run-commands-parallel.ts b/ng-dev/format/run-commands-parallel.ts index 865bc8cdc2..7538c4fd29 100644 --- a/ng-dev/format/run-commands-parallel.ts +++ b/ng-dev/format/run-commands-parallel.ts @@ -15,7 +15,10 @@ import {info} from '../utils/console'; import {Formatter, FormatterAction, getActiveFormatters} from './formatters/index'; -const AVAILABLE_THREADS = Math.max(cpus().length - 1, 1); +// Some environments, like CircleCI which use Docker report a number of CPUs by the host and not the count of available. +// This causes the task to be killed when formatting a large number of files due lack of resources. +// https://github.com/nodejs/node/issues/28762 +const AVAILABLE_THREADS = Math.max(Math.min(cpus().length, 8) - 1, 1); /** Interface describing a failure occurred during formatting of a file. */ export interface FormatFailure { diff --git a/tools/local-actions/changelog/main.js b/tools/local-actions/changelog/main.js index 62ee5bd299..d34fadc3fc 100644 --- a/tools/local-actions/changelog/main.js +++ b/tools/local-actions/changelog/main.js @@ -48561,7 +48561,7 @@ var require_run_commands_parallel = __commonJS({ var child_process_1 = require_child_process(); var console_1 = require_console(); var index_1 = require_formatters(); - var AVAILABLE_THREADS = Math.max((0, os_1.cpus)().length - 1, 1); + var AVAILABLE_THREADS = Math.max(Math.min((0, os_1.cpus)().length, 8) - 1, 1); function runFormatterInParallel(allFiles, action) { return new Promise((resolve) => { const formatters = (0, index_1.getActiveFormatters)();