My test suite runs without memory leaks.
My test suite leaks between 50 and 100mb between each lib/app run.
I'm guessing there's a bug somewhere, but can't say for sure where. I've tried to exclude Jest itself from the equation because the memory leak seems to happen between suites and not within a suite.
All I did was update to @nrwl/nx v7.7 and all related dependencies as usual. It wasn't leaking in v7.6.
So I guess if anyone has a repo using Jest unit tests, that's all that is needed.
Please provide any relevant information about your setup:
{
"@angular-devkit/build-angular": "0.13.7",
"@angular/animations": "7.2.11",
"@angular/cdk": "7.3.6",
"@angular/cli": "7.3.7",
"@angular/common": "7.2.11",
"@angular/compiler-cli": "7.2.11",
"@angular/compiler": "7.2.11",
"@angular/core": "7.2.11",
"@angular/flex-layout": "7.0.0-beta.24",
"@angular/forms": "7.2.11",
"@angular/http": "7.2.11",
"@angular/language-service": "7.2.11",
"@angular/material": "7.3.6",
"@angular/platform-browser-dynamic": "7.2.11",
"@angular/platform-browser": "7.2.11",
"@angular/platform-server": "7.2.11",
"@angular/router": "7.2.11",
"@ng-toolkit/serverless": "1.1.51",
"@ng-toolkit/universal": "1.1.51",
"@nguniversal/common": "7.1.1",
"@nguniversal/express-engine": "7.1.1",
"@nguniversal/module-map-ngfactory-loader": "7.1.1",
"@ngx-formly/core": "4.8.3",
"@ngx-formly/material": "4.8.3",
"@nrwl/builders": "7.6.0",
"@nrwl/nx": "7.6.0",
"@nrwl/schematics": "7.6.0",
"angular2-text-mask": "9.0.0",
"apollo-angular-link-http": "1.5.0",
"apollo-angular": "1.5.0",
"apollo-cache-inmemory": "1.5.1",
"apollo-client": "2.5.1",
"apollo-link-context": "1.0.17",
"apollo-link-error": "1.1.10",
"apollo-link-ws": "1.0.17",
"apollo-link": "1.2.11",
"aws-serverless-express": "3.3.6",
"codelyzer": "5.0.0",
"core-js": "2.6.5",
"cors": "2.8.5",
"cypress": "3.2.0",
"graphql-tag": "2.10.1",
"graphql": "14.2.1",
"hammerjs": "2.0.8",
"jest-junit": "6.3.0",
"jest-preset-angular": "6.0.2",
"jest": "23.6.0",
"ngx-custom-validators": "7.0.0",
"ngx-take-until-destroy": "5.4.0",
"rxjs": "6.4.0",
"text-mask-addons": "3.8.0",
"webpack-cli": "3.3.0",
"zone.js": "0.9.0",
}
Example run after the update:
[0K[32;1m$ cd ./packages/frontends[0;m
[32;1m$ node --version[0;m
v8.12.0
[32;1m$ node --expose-gc ./node_modules/.bin/ng test --ci --code-coverage=false --run-in-band[0;m
PASS apps/whitelabel/src/app/app.component.spec.ts (195 MB heap size)
AppComponent
✓ should create the app (87ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 5.168s
Ran all test suites.
PASS apps/backoffice/src/app/layout/layout.component.spec.ts (294 MB heap size)
PASS apps/backoffice/src/app/app.component.spec.ts (289 MB heap size)
Test Suites: 2 passed, 2 total
Tests: 3 passed, 3 total
Snapshots: 1 passed, 1 total
Time: 4.154s
Ran all test suites.
PASS libs/api/src/lib/api.module.spec.ts (364 MB heap size)
ApiModule
✓ should create (69ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 3.283s
Ran all test suites.
PASS libs/core/src/lib/user.service.spec.ts (427 MB heap size)
PASS libs/core/src/lib/auth.service.spec.ts (426 MB heap size)
PASS libs/core/src/lib/wallet.service.spec.ts (426 MB heap size)
PASS libs/core/src/lib/unauth.guard.spec.ts (428 MB heap size)
PASS libs/core/src/lib/auth.guard.spec.ts (428 MB heap size)
PASS libs/core/src/lib/route.service.spec.ts (426 MB heap size)
PASS libs/core/src/lib/core.module.spec.ts (426 MB heap size)
Test Suites: 7 passed, 7 total
Tests: 8 passed, 8 total
Snapshots: 0 total
Time: 6.945s
Ran all test suites.
PASS libs/ui/src/lib/form-errors/form-errors.component.spec.ts (507 MB heap size)
PASS libs/ui/src/lib/loader/loader.component.spec.ts (507 MB heap size)
PASS libs/ui/src/lib/css-url.pipe.spec.ts (506 MB heap size)
PASS libs/ui/src/lib/ui.module.spec.ts (526 MB heap size)
Test Suites: 4 passed, 4 total
Tests: 6 passed, 6 total
Snapshots: 2 passed, 2 total
Time: 6.525s
Ran all test suites.
PASS libs/registration/src/lib/registration-form/registration-form.component.spec.ts (5.068s, 633 MB heap size)
PASS libs/registration/src/lib/registration.module.spec.ts (628 MB heap size)
Test Suites: 2 passed, 2 total
Tests: 3 passed, 3 total
Snapshots: 1 passed, 1 total
Time: 7.861s
Ran all test suites.
PASS libs/casino-game/src/lib/casino-game/casino-game.component.spec.ts (687 MB heap size)
PASS libs/casino-game/src/lib/casino-game.module.spec.ts (685 MB heap size)
Test Suites: 2 passed, 2 total
Tests: 4 passed, 4 total
Snapshots: 1 passed, 1 total
Time: 3.839s
Ran all test suites.
PASS libs/documents/src/lib/document-upload-form/document-upload-form.component.spec.ts (736 MB heap size)
PASS libs/documents/src/lib/documents/documents.component.spec.ts (736 MB heap size)
PASS libs/documents/src/lib/documents.module.spec.ts (736 MB heap size)
Test Suites: 3 passed, 3 total
Tests: 5 passed, 5 total
Snapshots: 2 passed, 2 total
Time: 4.32s
Ran all test suites.
PASS libs/forgot-password/src/lib/forgot-password-form/forgot-password-form.component.spec.ts (818 MB heap size)
PASS libs/forgot-password/src/lib/forgot-password/forgot-password.component.spec.ts (818 MB heap size)
PASS libs/forgot-password/src/lib/forgot-password.module.spec.ts (837 MB heap size)
Test Suites: 3 passed, 3 total
Tests: 5 passed, 5 total
Snapshots: 2 passed, 2 total
Time: 7.06s
Ran all test suites.
PASS libs/reset-password/src/lib/reset-password-form/reset-password-form.component.spec.ts (922 MB heap size)
PASS libs/reset-password/src/lib/reset-password/reset-password.component.spec.ts (919 MB heap size)
PASS libs/reset-password/src/lib/reset-password.module.spec.ts (929 MB heap size)
Test Suites: 3 passed, 3 total
Tests: 5 passed, 5 total
Snapshots: 2 passed, 2 total
Time: 7.922s
Ran all test suites.
PASS libs/payment/src/lib/payment-process/payment-process.component.spec.ts (1018 MB heap size)
PASS libs/payment/src/lib/payment-option-list/payment-option-list.component.spec.ts (1016 MB heap size)
PASS libs/payment/src/lib/payment-option/payment-option.component.spec.ts (1011 MB heap size)
PASS libs/payment/src/lib/card-form/card-form.component.spec.ts (1013 MB heap size)
PASS libs/payment/src/lib/payment.service.spec.ts (1013 MB heap size)
PASS libs/payment/src/lib/payment.module.spec.ts (1032 MB heap size)
PASS libs/payment/src/lib/card-type-detector.directive.spec.ts (1023 MB heap size)
Test Suites: 7 passed, 7 total
Tests: 11 passed, 11 total
Snapshots: 4 passed, 4 total
Time: 14.741s
Ran all test suites.
PASS libs/fluid-container/src/lib/fluid-container/fluid-container.component.spec.ts (1081 MB heap size)
PASS libs/fluid-container/src/lib/fluid-container.module.spec.ts (1081 MB heap size)
Test Suites: 2 passed, 2 total
Tests: 3 passed, 3 total
Snapshots: 1 passed, 1 total
Time: 4.164s
Ran all test suites.
PASS libs/layout/src/lib/layout/layout.component.spec.ts (6.025s, 1181 MB heap size)
FAIL libs/layout/src/lib/sidebar/sidebar.component.spec.ts
● Test suite failed to run
TypeScript diagnostics (customize using `[jest-config].globals.ts-jest.diagnostics` option):
[96mlibs/layout/src/lib/sidebar/sidebar.component.spec.ts[0m:[93m26[0m:[93m7[0m - [91merror[0m[90m TS2739: [0mType '{ __typename: "NavList"; classes: string[]; navListItems: undefined[]; }' is missing the following properties from type 'NavList': horizontal, id
[7m26[0m navList: {
[7m [0m [91m ~~~~~~~[0m
[96mlibs/layout/src/lib/sidebar/sidebar.graphql.ts[0m:[93m8[0m:[93m3[0m
[7m8[0m navList: NavList;
[7m [0m [96m ~~~~~~~[0m
The expected type comes from property 'navList' which is declared here on type 'Sidebar'
PASS libs/layout/src/lib/header/header.component.spec.ts (1213 MB heap size)
PASS libs/layout/src/lib/footer/footer.component.spec.ts (1194 MB heap size)
PASS libs/layout/src/lib/layout.module.spec.ts (5.055s, 1212 MB heap size)
Test Suites: 1 failed, 4 passed, 5 total
Tests: 7 passed, 7 total
Snapshots: 3 passed, 3 total
Time: 19.157s
Ran all test suites.
PASS libs/cms/src/lib/page/page.component.spec.ts (7.531s, 1269 MB heap size)
PASS libs/cms/src/lib/dialog-route/dialog-route.component.spec.ts (1271 MB heap size)
PASS libs/cms/src/lib/content-group/content-group.component.spec.ts (1272 MB heap size)
PASS libs/cms/src/lib/cms.service.spec.ts (1270 MB heap size)
PASS libs/cms/src/lib/slot.directive.spec.ts (1268 MB heap size)
PASS libs/cms/src/lib/cms.module.spec.ts (1270 MB heap size)
Test Suites: 6 passed, 6 total
Tests: 9 passed, 9 total
Snapshots: 3 passed, 3 total
Time: 18.367s
Ran all test suites.
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
<--- Last few GCs --->
[10:0x2510510] 136242 ms: Mark-sweep 1362.8 (1460.0) -> 1362.8 (1460.0) MB, 1827.9 / 0.1 ms allocation failure GC in old space requested
[10:0x2510510] 137760 ms: Mark-sweep 1362.8 (1460.0) -> 1362.8 (1429.0) MB, 1518.2 / 0.1 ms last resort GC in old space requested
[10:0x2510510] 139285 ms: Mark-sweep 1362.8 (1429.0) -> 1362.8 (1429.0) MB, 1524.6 / 0.1 ms last resort GC in old space requested
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0xb1cf5fa5879 <JSObject>
1: stringSlice(aka stringSlice) [buffer.js:560] [bytecode=0x1e161b35dd29 offset=94](this=0x11a4d26822d1 <undefined>,buf=0x20928062d71 <Uint8Array map = 0x35a39b242941>,encoding=0xb1cf5fb5409 <String[4]: utf8>,start=0,end=1097377)
2: toString [buffer.js:633] [bytecode=0x1e161b35d979 offset=145](this=0x20928062d71 <Uint8Array map = 0x35a39b242941>,encoding=0xb1cf5fb5409 <String[4]: utf8>,st...
1: node::Abort() [ng test --ci --code-coverage=false --run-in-band]
2: 0x8cbf4c [ng test --ci --code-coverage=false --run-in-band]
3: v8::Utils::ReportOOMFailure(char const*, bool) [ng test --ci --code-coverage=false --run-in-band]
4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [ng test --ci --code-coverage=false --run-in-band]
5: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [ng test --ci --code-coverage=false --run-in-band]
6: v8::internal::Factory::NewStringFromUtf8(v8::internal::Vector<char const>, v8::internal::PretenureFlag) [ng test --ci --code-coverage=false --run-in-band]
7: v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::NewStringType, int) [ng test --ci --code-coverage=false --run-in-band]
8: node::StringBytes::Encode(v8::Isolate*, char const*, unsigned long, node::encoding, v8::Local<v8::Value>*) [ng test --ci --code-coverage=false --run-in-band]
9: 0x8e4a76 [ng test --ci --code-coverage=false --run-in-band]
10: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [ng test --ci --code-coverage=false --run-in-band]
11: 0xb0bbec [ng test --ci --code-coverage=false --run-in-band]
12: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [ng test --ci --code-coverage=false --run-in-band]
13: 0x220bb08042fd
/bin/bash: line 90: 10 Aborted (core dumped) node --expose-gc ./node_modules/.bin/ng test --ci --code-coverage=false --run-in-band
section_end:1554216631:build_script
[0Ksection_start:1554216631:after_script
[0Ksection_end:1554216633:after_script
[0Ksection_start:1554216633:upload_artifacts_on_failure
[0K[32;1mUploading artifacts...[0;m
[0;33mWARNING: ./packages/frontends/junit/*.xml: no matching files[0;m
[31;1mERROR: No files to upload [0;m
section_end:1554216634:upload_artifacts_on_failure
[0K[31;1mERROR: Job failed: exit code 1
@nrwl/nx v7.7 includes a new version of jest-preset-angular (v7.x) which itself uses a new version of ts-jest. In the new version of ts-jest the option diagnostics is enabled by default. And this option cannot be overwritten since the jest builder of nx hard codes the ts-jest options. This leads to the following problems:
So it would be nice if there is an option added in nx to disable the diagnostics in ts-jest.
But anyway, if your app gets bigger at some you will reach the default memory limit in node.js (~1.5 GB). We already have that problem. As suggested in the @angular/cli repo we manually increase the memory limit for all test and build runs.
node --max-old-space-size=4096 ./node_modules/.bin/nx affected:test --base=master
I'm aware that we will need more memory at some point but before the update, ~500mb was enough.
More memory being needed or even tests being slower is not really a problem. The problem is that no memory is being freed between test suites as you can see in my log.
I'll create a patch to disable diagnostics in ts-jest and report back.
I've created a patch to disable diagnostics but memory is still leaking. ):
This is the patch:
diff --git a/node_modules/@nrwl/builders/src/jest/jest.builder.js b/node_modules/@nrwl/builders/src/jest/jest.builder.js
index b87e9e5..434d3ed 100755
--- a/node_modules/@nrwl/builders/src/jest/jest.builder.js
+++ b/node_modules/@nrwl/builders/src/jest/jest.builder.js
@@ -14,6 +14,7 @@ var JestBuilder = /** @class */ (function () {
JestBuilder.prototype.run = function (builderConfig) {
var options = builderConfig.options;
var tsJestConfig = {
+ diagnostics: false,
tsConfig: path.join('<rootDir>', path.relative(builderConfig.root, options.tsConfig))
};
// TODO: This is hacky, We should probably just configure it in the user's workspace
@@ -29,6 +30,8 @@ var JestBuilder = /** @class */ (function () {
}
catch (e) { }
var config = {
+ detectOpenHandles: true,
+ logHeapUsage: true,
watch: options.watch,
coverage: options.codeCoverage,
bail: options.bail,
This is the new log:
$ node --version
v8.12.0
$ node --expose-gc ./node_modules/.bin/ng test --ci --code-coverage=false --run-in-band
PASS apps/whitelabel/src/app/app.component.spec.ts (163 MB heap size)
AppComponent
✓ should create the app (118ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 5.506s
Ran all test suites.
PASS apps/backoffice/src/app/layout/layout.component.spec.ts (271 MB heap size)
PASS apps/backoffice/src/app/app.component.spec.ts (265 MB heap size)
Test Suites: 2 passed, 2 total
Tests: 3 passed, 3 total
Snapshots: 1 passed, 1 total
Time: 6.17s
Ran all test suites.
PASS libs/api/src/lib/api.module.spec.ts (340 MB heap size)
ApiModule
✓ should create (85ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 4.956s
Ran all test suites.
PASS libs/core/src/lib/user.service.spec.ts (403 MB heap size)
PASS libs/core/src/lib/auth.service.spec.ts (403 MB heap size)
PASS libs/core/src/lib/wallet.service.spec.ts (403 MB heap size)
PASS libs/core/src/lib/unauth.guard.spec.ts (404 MB heap size)
PASS libs/core/src/lib/auth.guard.spec.ts (405 MB heap size)
PASS libs/core/src/lib/route.service.spec.ts (403 MB heap size)
PASS libs/core/src/lib/core.module.spec.ts (402 MB heap size)
Test Suites: 7 passed, 7 total
Tests: 8 passed, 8 total
Snapshots: 0 total
Time: 9.808s
Ran all test suites.
PASS libs/ui/src/lib/form-errors/form-errors.component.spec.ts (483 MB heap size)
PASS libs/ui/src/lib/loader/loader.component.spec.ts (483 MB heap size)
PASS libs/ui/src/lib/css-url.pipe.spec.ts (482 MB heap size)
PASS libs/ui/src/lib/ui.module.spec.ts (502 MB heap size)
Test Suites: 4 passed, 4 total
Tests: 6 passed, 6 total
Snapshots: 2 passed, 2 total
Time: 8.92s
Ran all test suites.
PASS libs/registration/src/lib/registration-form/registration-form.component.spec.ts (6.896s, 609 MB heap size)
PASS libs/registration/src/lib/registration.module.spec.ts (605 MB heap size)
Test Suites: 2 passed, 2 total
Tests: 3 passed, 3 total
Snapshots: 1 passed, 1 total
Time: 10.768s
Ran all test suites.
PASS libs/casino-game/src/lib/casino-game/casino-game.component.spec.ts (663 MB heap size)
PASS libs/casino-game/src/lib/casino-game.module.spec.ts (662 MB heap size)
Test Suites: 2 passed, 2 total
Tests: 4 passed, 4 total
Snapshots: 1 passed, 1 total
Time: 5.49s
Ran all test suites.
PASS libs/documents/src/lib/document-upload-form/document-upload-form.component.spec.ts (712 MB heap size)
PASS libs/documents/src/lib/documents/documents.component.spec.ts (713 MB heap size)
PASS libs/documents/src/lib/documents.module.spec.ts (712 MB heap size)
Test Suites: 3 passed, 3 total
Tests: 5 passed, 5 total
Snapshots: 2 passed, 2 total
Time: 6.345s
Ran all test suites.
PASS libs/forgot-password/src/lib/forgot-password-form/forgot-password-form.component.spec.ts (795 MB heap size)
PASS libs/forgot-password/src/lib/forgot-password/forgot-password.component.spec.ts (795 MB heap size)
PASS libs/forgot-password/src/lib/forgot-password.module.spec.ts (814 MB heap size)
Test Suites: 3 passed, 3 total
Tests: 5 passed, 5 total
Snapshots: 2 passed, 2 total
Time: 9.84s
Ran all test suites.
PASS libs/reset-password/src/lib/reset-password-form/reset-password-form.component.spec.ts (899 MB heap size)
PASS libs/reset-password/src/lib/reset-password/reset-password.component.spec.ts (896 MB heap size)
PASS libs/reset-password/src/lib/reset-password.module.spec.ts (906 MB heap size)
Test Suites: 3 passed, 3 total
Tests: 5 passed, 5 total
Snapshots: 2 passed, 2 total
Time: 11.284s
Ran all test suites.
PASS libs/payment/src/lib/payment-process/payment-process.component.spec.ts (994 MB heap size)
PASS libs/payment/src/lib/payment-option-list/payment-option-list.component.spec.ts (993 MB heap size)
PASS libs/payment/src/lib/payment-option/payment-option.component.spec.ts (988 MB heap size)
PASS libs/payment/src/lib/card-form/card-form.component.spec.ts (989 MB heap size)
PASS libs/payment/src/lib/payment.service.spec.ts (989 MB heap size)
PASS libs/payment/src/lib/payment.module.spec.ts (1009 MB heap size)
PASS libs/payment/src/lib/card-type-detector.directive.spec.ts (999 MB heap size)
Test Suites: 7 passed, 7 total
Tests: 11 passed, 11 total
Snapshots: 4 passed, 4 total
Time: 21.367s
Ran all test suites.
PASS libs/fluid-container/src/lib/fluid-container/fluid-container.component.spec.ts (1058 MB heap size)
PASS libs/fluid-container/src/lib/fluid-container.module.spec.ts (1057 MB heap size)
Test Suites: 2 passed, 2 total
Tests: 3 passed, 3 total
Snapshots: 1 passed, 1 total
Time: 6.397s
Ran all test suites.
PASS libs/layout/src/lib/header/header.component.spec.ts (10.815s, 1179 MB heap size)
PASS libs/layout/src/lib/layout/layout.component.spec.ts (6.545s, 1171 MB heap size)
PASS libs/layout/src/lib/sidebar/sidebar.component.spec.ts (1170 MB heap size)
PASS libs/layout/src/lib/footer/footer.component.spec.ts (1168 MB heap size)
PASS libs/layout/src/lib/layout.module.spec.ts (9.415s, 1183 MB heap size)
Test Suites: 5 passed, 5 total
Tests: 9 passed, 9 total
Snapshots: 4 passed, 4 total
Time: 36.706s
Ran all test suites.
PASS libs/cms/src/lib/page/page.component.spec.ts (12.916s, 1274 MB heap size)
PASS libs/cms/src/lib/dialog-route/dialog-route.component.spec.ts (1285 MB heap size)
PASS libs/cms/src/lib/content-group/content-group.component.spec.ts (1285 MB heap size)
PASS libs/cms/src/lib/cms.service.spec.ts (1283 MB heap size)
PASS libs/cms/src/lib/slot.directive.spec.ts (1281 MB heap size)
PASS libs/cms/src/lib/cms.module.spec.ts (1283 MB heap size)
Test Suites: 6 passed, 6 total
Tests: 9 passed, 9 total
Snapshots: 3 passed, 3 total
Time: 31.64s
Ran all test suites.
<--- Last few GCs --->
[10:0x2fd1510] 222463 ms: Mark-sweep 1375.8 (1467.3) -> 1375.7 (1467.8) MB, 2139.9 / 0.2 ms allocation failure GC in old space requested
[10:0x2fd1510] 224082 ms: Mark-sweep 1375.7 (1467.8) -> 1375.7 (1436.8) MB, 1619.1 / 0.3 ms last resort GC in old space requested
[10:0x2fd1510] 226289 ms: Mark-sweep 1375.7 (1436.8) -> 1375.7 (1436.8) MB, 2206.8 / 0.2 ms last resort GC in old space requested
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x1c67cf425879 <JSObject>
1: stringSlice(aka stringSlice) [buffer.js:560] [bytecode=0x1eb68eeddd29 offset=94](this=0x1432ca7822d1 <undefined>,buf=0xbae293346b1 <Uint8Array map = 0x2948f8b42941>,encoding=0x1c67cf435409 <String[4]: utf8>,start=0,end=1097377)
2: toString [buffer.js:633] [bytecode=0x1eb68eedd979 offset=145](this=0xbae293346b1 <Uint8Array map = 0x2948f8b42941>,encoding=0x1c67cf435409 <String[4]: utf8>...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [ng test --ci --code-coverage=false --run-in-band]
2: 0x8cbf4c [ng test --ci --code-coverage=false --run-in-band]
3: v8::Utils::ReportOOMFailure(char const*, bool) [ng test --ci --code-coverage=false --run-in-band]
4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [ng test --ci --code-coverage=false --run-in-band]
5: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [ng test --ci --code-coverage=false --run-in-band]
6: v8::internal::Factory::NewStringFromUtf8(v8::internal::Vector<char const>, v8::internal::PretenureFlag) [ng test --ci --code-coverage=false --run-in-band]
7: v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::NewStringType, int) [ng test --ci --code-coverage=false --run-in-band]
8: node::StringBytes::Encode(v8::Isolate*, char const*, unsigned long, node::encoding, v8::Local<v8::Value>*) [ng test --ci --code-coverage=false --run-in-band]
9: 0x8e4a76 [ng test --ci --code-coverage=false --run-in-band]
10: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [ng test --ci --code-coverage=false --run-in-band]
11: 0xb0bbec [ng test --ci --code-coverage=false --run-in-band]
12: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [ng test --ci --code-coverage=false --run-in-band]
13: 0x23cefd2842fd
/bin/bash: line 91: 10 Aborted (core dumped) node --expose-gc ./node_modules/.bin/ng test --ci --code-coverage=false --run-in-band
Great debugging!
Can you reproduce with a more minmal project? It seems the way jest requires modules has some memory leaks when used with certain libraries?
https://github.com/facebook/jest/issues/8247
With my test project, I see this: which may have a more minor memory leak?
LOGS
Jasons-MacBook-Pro:reacttest jason$ node --expose-gc ./node_modules/.bin/ng test ngapp --run-in-band
PASS apps/ngapp/src/app/app.component4.spec.ts (90 MB heap size)
PASS apps/ngapp/src/app/app.component17.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component7.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component10.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component2.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component53.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component18.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component6.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component12.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component9.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component16.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component5.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component11.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component3.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component8.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component1.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component52.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component21.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component34.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component46.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component31.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component40.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component30.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component51.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component32.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component47.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component43.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component35.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component54.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component25.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component49.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component23.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component44.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component22.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component38.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component33.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component28.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component27.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component42.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component37.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component41.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component45.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component39.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component19.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component29.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component36.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component20.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component26.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component24.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component48.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component50.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component13.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component15.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component14.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component.spec.ts (96 MB heap size)
Test Suites: 55 passed, 55 total
Tests: 165 passed, 165 total
Snapshots: 0 total
Time: 15.073s
Ran all test suites.
Jasons-MacBook-Pro:reacttest jason$ node --expose-gc ./node_modules/.bin/ng test ngapp --run-in-band
PASS apps/ngapp/src/app/app.component88.spec.ts (90 MB heap size)
PASS apps/ngapp/src/app/app.component66.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component78.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component68.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component76.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component99.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component89.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component85.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component95.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component80.spec.ts (95 MB heap size)
PASS apps/ngapp/src/app/app.component57.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component90.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component92.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component61.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component82.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component71.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component104.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component106.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component63.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component102.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component59.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component94.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component73.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component84.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component101.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component64.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component87.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component74.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component97.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component70.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component55.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component60.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component108.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component56.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component72.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component91.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component62.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component81.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component77.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component107.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component100.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component69.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component67.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component65.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component96.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component75.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component93.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component79.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component83.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component98.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component58.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component103.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component31.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component105.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component35.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component86.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component4.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component53.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component17.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component7.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component54.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component43.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component49.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component10.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component44.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component29.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component48.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component38.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component2.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component18.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component22.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component32.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component27.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component36.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component46.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component5.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component25.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component28.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component11.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component52.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component50.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component21.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component23.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component14.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component33.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component51.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component45.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component19.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component20.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component47.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component41.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component24.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component40.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component34.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component42.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component37.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component26.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component1.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component39.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component30.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component16.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component13.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component3.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component8.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component6.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component15.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component.spec.ts (96 MB heap size)
PASS apps/ngapp/src/app/app.component9.spec.ts (97 MB heap size)
PASS apps/ngapp/src/app/app.component12.spec.ts (96 MB heap size)
Test Suites: 109 passed, 109 total
Tests: 327 passed, 327 total
Snapshots: 0 total
Time: 27.466s
Ran all test suites.
Jasons-MacBook-Pro:reacttest jason$
@FrozenPandaz it works fine locally actually. My logs are from GitLab runners.
I'm a bit short of time right now, but I'll see if I can come up with some repo. ):
Hi, I have the same error, but I'm running my test suite on TravisCI, here is the repo I'm working on:
https://github.com/llstarscreamll/angular-kirby
I have tried many things to fix the error, but nothing works... some links:
https://github.com/facebook/jest/issues/7647
https://github.com/facebook/jest/issues/2179
Here is the logs from my failed builds:
https://github.com/llstarscreamll/angular-kirby
On my local machine all the tests are green.
Hi every one, my build is now passing!! I upgrade some dependencies and change TravisCI setup to this:
language: node_js
node_js: 12
dist: trusty
sudo: required
cache:
npm: false
install:
- yarn install --network-timeout 1000000
notifications:
email: true
branches:
except:
- /^v\d+\.\d+\.\d+$/
script: ng test -i --ci --bail=1 --pass-with-no-tests
@llstarscreamll what dependencies did you upgrade to make the build pass?
Here is the diffs from the dependencies changes, including the TravisCI setup:
https://github.com/llstarscreamll/angular-kirby/commit/b2e2a3b3736fe6404d686709c671f110436fbabe
https://github.com/llstarscreamll/angular-kirby/commit/e48f6166cc244ed187f0fe47edc48563f46d9133
https://github.com/llstarscreamll/angular-kirby/commit/a42c2f42802ef240f5ade437744a7296674af7b5
https://github.com/llstarscreamll/angular-kirby/commit/e9110aea66625343b19d7ae7c44c155516322042
Just confirming. It looks like the issue has been fixed in 8.5. Right?
Closing this issue due to inactivity. If the problem persists, please reopen the issue. Thank you.