diff --git a/.changeset/cli-pack-so-exhausting.md b/.changeset/cli-pack-so-exhausting.md new file mode 100644 index 0000000000..e4f92521d0 --- /dev/null +++ b/.changeset/cli-pack-so-exhausting.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Fixed a bug that could cause the `build-workspace` command to fail when invoked with `--alwaysYarnPack` enabled in environments with limited resources. diff --git a/packages/cli/package.json b/packages/cli/package.json index 910769ff06..163c204ec7 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -112,6 +112,7 @@ "node-libs-browser": "^2.2.1", "npm-packlist": "^5.0.0", "ora": "^5.3.0", + "p-limit": "^3.1.0", "p-queue": "^6.6.2", "postcss": "^8.1.0", "process": "^0.11.10", diff --git a/packages/cli/src/lib/packager/createDistWorkspace.ts b/packages/cli/src/lib/packager/createDistWorkspace.ts index 00b8784d6d..9cb54f2830 100644 --- a/packages/cli/src/lib/packager/createDistWorkspace.ts +++ b/packages/cli/src/lib/packager/createDistWorkspace.ts @@ -21,6 +21,7 @@ import { resolve as resolvePath, relative as relativePath, } from 'path'; +import pLimit from 'p-limit'; import { tmpdir } from 'os'; import tar, { CreateOptions, FileOptions } from 'tar'; import partition from 'lodash/partition'; @@ -352,9 +353,11 @@ async function moveToDistWorkspace( } // Repacking in parallel is much faster and safe for all packages outside of the Backstage repo + // Limit concurrency to 10 to avoid resource exhaustion on larger monorepos. + const limit = pLimit(10); await Promise.all( - safePackages.map(async (target, index) => - pack(target, `temp-package-${index}.tgz`), + safePackages.map((target, index) => + limit(() => pack(target, `temp-package-${index}.tgz`)), ), ); } diff --git a/yarn.lock b/yarn.lock index 0f498305c3..bb31f75913 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3691,6 +3691,7 @@ __metadata: nodemon: ^3.0.1 npm-packlist: ^5.0.0 ora: ^5.3.0 + p-limit: ^3.1.0 p-queue: ^6.6.2 postcss: ^8.1.0 process: ^0.11.10