Skip to content

Commit 4367c3a

Browse files
committed
fix(@angular-devkit/build-angular): add NG_BUILD_MAX_WORKERS settimgs to control maximum number of workers
1 parent 0ebf756 commit 4367c3a

File tree

5 files changed

+16
-28
lines changed

5 files changed

+16
-28
lines changed

packages/angular_devkit/build_angular/src/utils/action-executor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import * as os from 'os';
1111
import * as path from 'path';
1212
import { serialize } from 'v8';
1313
import { BundleActionCache } from './action-cache';
14+
import { maxWorkers } from './environment-options';
1415
import { I18nOptions } from './i18n-options';
1516
import { InlineOptions, ProcessBundleOptions, ProcessBundleResult } from './process-bundle';
16-
import { maxWorkers } from './workers';
1717

1818
let workerFile = require.resolve('./process-bundle');
1919
workerFile =
@@ -35,7 +35,7 @@ export class BundleActionExecutor {
3535
}
3636

3737
private static executeMethod<O>(worker: JestWorker, method: string, input: unknown): Promise<O> {
38-
return ((worker as unknown) as Record<string, (i: unknown) => Promise<O>>)[method](input);
38+
return (worker as unknown as Record<string, (i: unknown) => Promise<O>>)[method](input);
3939
}
4040

4141
private ensureLarge(): JestWorker {

packages/angular_devkit/build_angular/src/utils/environment-options.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,15 @@ export const cachingBasePath = (() => {
8383
// Build profiling
8484
const profilingVariable = process.env['NG_BUILD_PROFILING'];
8585
export const profilingEnabled = isPresent(profilingVariable) && isEnabled(profilingVariable);
86+
87+
/**
88+
* Some environments, like CircleCI which use Docker report a number of CPUs by the host and not the count of available.
89+
* This cause `Error: Call retries were exceeded` errors when trying to use them.
90+
*
91+
* @see https://github.com/nodejs/node/issues/28762
92+
* @see https://github.com/webpack-contrib/terser-webpack-plugin/issues/143
93+
* @see https://ithub.com/angular/angular-cli/issues/16860#issuecomment-588828079
94+
*
95+
*/
96+
const maxWorkersVariable = process.env['NG_BUILD_MAX_WORKERS'];
97+
export const maxWorkers = isPresent(maxWorkersVariable) ? +maxWorkersVariable : 4;

packages/angular_devkit/build_angular/src/utils/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ export * from './normalize-source-maps';
1616
export * from './normalize-optimization';
1717
export * from './normalize-builder-schema';
1818
export * from './url';
19-
export * from './workers';

packages/angular_devkit/build_angular/src/utils/workers.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

packages/angular_devkit/build_angular/src/webpack/configs/common.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ import {
2323
debug,
2424
} from 'webpack';
2525
import { AssetPatternClass } from '../../browser/schema';
26-
import { BuildBrowserFeatures, maxWorkers } from '../../utils';
26+
import { BuildBrowserFeatures } from '../../utils';
2727
import { WebpackConfigOptions } from '../../utils/build-options';
2828
import { findCachePath } from '../../utils/cache-path';
2929
import {
3030
allowMangle,
3131
allowMinify,
3232
cachingDisabled,
33+
maxWorkers,
3334
profilingEnabled,
3435
shouldBeautify,
3536
} from '../../utils/environment-options';

0 commit comments

Comments
 (0)