diff --git a/.projenrc.ts b/.projenrc.ts index f8973c50..123366b6 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -324,7 +324,15 @@ const backEndApp = new awscdk.AwsCdkTypeScriptApp({ eslint: true, jest: true, jestOptions: { + // Recycle a worker once it exceeds this heap so accumulated memory (v8 coverage + + // CDK synth) is freed between suites rather than growing for the worker's lifetime. + extraCliOptions: ['--workerIdleMemoryLimit=2GB'], jestConfig: { + // Cap parallelism. The test/infra/** suites each synthesize full CDK stacks and use + // ~1.4GB heap apiece; at the default (cpuCount-1) worker count their aggregate RSS, + // plus v8 coverage, exceeds the 16GB CI runner and the OS OOM-kills the run (exit 1 + // with no Jest summary). Limiting workers keeps peak memory well under the runner. + maxWorkers: '50%', // Ensure Jest can resolve tsconfig path aliases used by lambda handlers/tests. moduleNameMapper: { '^@BE/(.*)$': '/src/app/$1', diff --git a/packages/back-end/.projen/tasks.json b/packages/back-end/.projen/tasks.json index 5d4a1a36..58b437f0 100644 --- a/packages/back-end/.projen/tasks.json +++ b/packages/back-end/.projen/tasks.json @@ -140,7 +140,7 @@ "description": "Run tests", "steps": [ { - "exec": "jest --passWithNoTests --updateSnapshot", + "exec": "jest --workerIdleMemoryLimit=2GB --passWithNoTests --updateSnapshot", "receiveArgs": true }, { diff --git a/packages/back-end/package.json b/packages/back-end/package.json index 7622285b..824538a1 100644 --- a/packages/back-end/package.json +++ b/packages/back-end/package.json @@ -109,6 +109,7 @@ "version": "0.0.0", "jest": { "coverageProvider": "v8", + "maxWorkers": "50%", "moduleNameMapper": { "^@BE/(.*)$": "/src/app/$1", "^@SharedLib/(.*)$": "/../shared-lib/src/app/$1",