-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Description
Version
30.0.2
Steps to reproduce
- Upgrade jest version for master.
- Ci now fails with memory error
Expected behavior
I expected memory usage to remain steady, on par with version 29.6.2 which we upgraded from.
Actual behavior
When I logHeapUsage, I see memory rises after every suite, beyond the limit set by workerIdleMemoryLimit. globalsCleanup value seems to have no effect on this outcome.
Every suite usage rises by about 100MB, until out of memory is reached.
I'm including system info for my local machine since it reproduces there as well.
I'm not sure if the leak is caused by a problem in the jest infrastructure or in our own testing infrastructure, but since upgrading is the only change in the relevant PR, I'm looking for advice at the very least.
Additional context
command line for jest:
node --expose-gc --no-compilation-cache node_modules/.bin/jest --logHeapUsage --coverage --runInBand --forceExit --testEnvironmentOptions={ "globalsCleanup": "on" } --workerIdleMemoryLimit=2048MB
package json config:
"jest": {
"moduleDirectories": [
"node_modules",
"<rootDir>"
],
"moduleNameMapper": {
"^type-fest$": "<rootDir>/node_modules/type-fest/index.d.ts"
},
"modulePathIgnorePatterns": [
"malformed_package_json/*",
"web-streams-polyfill/.*/.*",
"dist",
"<rootDir>/prod_node_modules/@redis/client/dist",
"<rootDir>/prod_node_modules/string-width-cjs",
"<rootDir>/prod_node_modules/strip-ansi-cjs"
],
"automock": false,
"preset": "ts-jest",
"setupFiles": [
"<rootDir>/src/initialize-imports-side-effects.ts",
"<rootDir>/src/test-utils/setup-jest-fetch-mock.ts",
"jest-fix-undefined"
],
"setupFilesAfterEnv": [
"jest-extended/all",
"<rootDir>/src/test-utils/global-setup.ts"
],
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": ".",
"testEnvironment": "node",
"testEnvironmentOptions": {
"globalsCleanup": "on"
},
"testMatch": [
"**/src/**/*spec.ts"
],
"transform": {
"^.+\\.(t|j)s$": [
"ts-jest",
{
"tsconfig": "tsconfig.json"
}
]
},
"collectCoverageFrom": [
"src/**/*.ts",
"!src/test-utils/**/*.ts",
"!src/**/*.test-*.*",
"!src/database/factories/*.ts",
"!src/**/*.seed.ts",
"!src/**/migrations/*.ts",
"!src/main.ts",
"!src/logger.ts"
],
"coverageDirectory": "coverage",
"coverageReporters": [
"json"
],
"testTimeout": 150000,
"workerIdleMemoryLimit": "1024MB",
"reporters": [
"default",
"jest-junit",
[
"<rootDir>/src/test-utils/jest-reporters/slow-test",
{
"numTests": 10
}
]
],
"verbose": true,
"silent": false
},
Environment
System:
OS: macOS 15.5
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Binaries:
Node: 22.15.0 - ~/.nvm/versions/node/v22.15.0/bin/node
Yarn: 1.22.22 - /usr/local/bin/yarn
npm: 10.9.2 - ~/.nvm/versions/node/v22.15.0/bin/npm
npmPackages:
jest: ^30.0.2 => 30.0.2