From 1857138e74acf4499c33f2f99ed827eec211dc0f Mon Sep 17 00:00:00 2001 From: Craigory Coppola Date: Thu, 14 Apr 2022 17:08:47 -0400 Subject: [PATCH] fix(core): build-project-graph shouldn't fail when large number of workers are available (#9804) fixes #9801 --- packages/nx/src/project-graph/build-project-graph.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/nx/src/project-graph/build-project-graph.ts b/packages/nx/src/project-graph/build-project-graph.ts index 7069b1f7df..5b6d46cf93 100644 --- a/packages/nx/src/project-graph/build-project-graph.ts +++ b/packages/nx/src/project-graph/build-project-graph.ts @@ -49,7 +49,6 @@ export async function buildProjectGraph() { const cacheEnabled = process.env.NX_CACHE_PROJECT_GRAPH !== 'false'; let cache = cacheEnabled ? readCache() : null; - return ( await buildProjectGraphUsingProjectFileMap( workspaceJson, @@ -292,7 +291,10 @@ function buildExplicitDependenciesUsingWorkers( totalNumOfFilesToProcess: number, builder: ProjectGraphBuilder ) { - const numberOfWorkers = getNumberOfWorkers(); + const numberOfWorkers = Math.min( + totalNumOfFilesToProcess, + getNumberOfWorkers() + ); const bins = splitFilesIntoBins( ctx, totalNumOfFilesToProcess,