diff --git a/.changeset/chatty-owls-care.md b/.changeset/chatty-owls-care.md new file mode 100644 index 0000000000..84b6fc76f6 --- /dev/null +++ b/.changeset/chatty-owls-care.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +The `backstage-cli repo test` command now sets a default Jest `--workerIdleMemoryLimit` of 1GB. This is the recommended workaround for dealing with Jest workers leaking memory and eventually hitting the heap limit. diff --git a/packages/cli/src/commands/repo/test.ts b/packages/cli/src/commands/repo/test.ts index 95bfe8f449..69b3d914ed 100644 --- a/packages/cli/src/commands/repo/test.ts +++ b/packages/cli/src/commands/repo/test.ts @@ -84,6 +84,13 @@ export async function command(opts: OptionValues, cmd: Command): Promise { } } + // When running tests from the repo root in large repos you can easily hit the heap limit. + // This is because Jest workers leak a lot of memory, and the workaround is to limit worker memory. + // We set a default memory limit, but if an explicit one is supplied it will be used instead + if (!args.some(arg => arg.match(/^--workerIdleMemoryLimit/))) { + args.push('--workerIdleMemoryLimit=1000M'); + } + if (opts.since) { removeOptionArg(args, '--since'); }