cli: set a default jest worker memory limit

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-01-26 12:09:34 +01:00
parent 7c0a33390a
commit 561df21ea3
2 changed files with 12 additions and 0 deletions
+5
View File
@@ -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.
+7
View File
@@ -84,6 +84,13 @@ export async function command(opts: OptionValues, cmd: Command): Promise<void> {
}
}
// 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');
}