While running e2e test I should not receive a JavaScript heap out of memory error
While running e2e testing on test 23 of 26 I receive the following message.
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 00007FF62E2507BF uv_open_osfhandle+479
2: 00007FF62CFC9786 node::Abort+22
3: 00007FF62CFC9DA3 node::Abort+1587
4: 00007FF62B5964F8 v8::RetainedObjectInfo::GetElementCount+808
5: 00007FF62B596493 v8::RetainedObjectInfo::GetElementCount+707
6: 00007FF62B60F133 std::_Vector_alloc<std::_Vec_base_types<v8::CpuProfileDeoptInfo,std::allocator<v8::CpuProfileDeoptInfo> > >::_Make_iterator+255075
7: 00007FF62B60E05B std::_Vector_alloc<std::_Vec_base_types<v8::CpuProfileDeoptInfo,std::allocator<v8::CpuProfileDeoptInfo> > >::_Make_iterator+250763
8: 00007FF62B60B6BF std::_Vector_alloc<std::_Vec_base_types<v8::CpuProfileDeoptInfo,std::allocator<v8::CpuProfileDeoptInfo> > >::_Make_iterator+240111
9: 00007FF62B615409 std::_Vector_alloc<std::_Vec_base_types<v8::CpuProfileDeoptInfo,std::allocator<v8::CpuProfileDeoptInfo> > >::_Make_iterator+280377
10: 00007FF62B615A8E std::_Vector_alloc<std::_Vec_base_types<v8::CpuProfileDeoptInfo,std::allocator<v8::CpuProfileDeoptInfo> > >::_Make_iterator+282046
11: 00007FF62B9DF067 std::_Vector_alloc<std::_Vec_base_types<v8::CpuProfileDeoptInfo,std::allocator<v8::CpuProfileDeoptInfo> > >::_Make_iterator+4252567
12: 00007FF62BBC20A9 std::_Vector_alloc<std::_Vec_base_types<v8::CpuProfileDeoptInfo,std::allocator<v8::CpuProfileDeoptInfo> > >::_Make_iterator+6231001
13: 00007FF62BF1AFAF v8::WasmStreaming::Unpack+2677935
Please provide detailed steps for reproducing the issue.
Please provide any relevant information about your setup:
@nrwl/angular : 8.8.2
@nrwl/cli : 8.8.2
@nrwl/cypress : 8.8.2
@nrwl/eslint-plugin-nx : Not Found
@nrwl/express : Not Found
@nrwl/jest : 8.8.2
@nrwl/linter : Not Found
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 8.8.2
@nrwl/web : Not Found
@nrwl/workspace : 8.8.2
typescript : 3.5.3
See above
Researching I found that this issue was reported before and closed in #1871, then possibly reintroduced in PR #1920 https://github.com/nrwl/nx/commit/08f3844007b0224f33b9d78b057a9176b672a0d4#diff-1fdd8c5d37dfa7a97c04b3b7e4c64fafL42 and researching the error I see many solutions pointing towards transpileOnly.
I created a demo workspace to reproduce this issue https://github.com/JoA-MoS/nx-example/tree/cypress-js-heap-oom
git clone https://github.com/JoA-MoS/nx-example.git
git checkout cypress-js-heap-oom
npm install
ng e2e demo-ui-e2e --headless --prod
relates to: https://github.com/cypress-io/cypress/issues/2316
Hi @JoA-MoS - thanks for raising this. Can you retry with the latest version?
@JoA-MoS we are updating the version of cypress to 3.6.1 in the next release, so they issue can be fixed there. Meanwhile, you could change your script to something like that:
"nx": "node --max-old-space-size=8192 ./node_modules/.bin/nx",
"ng": "node --max-old-space-size=8192 ./node_modules/.bin/ng"
So when you run npm rug ng -- run e2e deemo-ui-e2e --headless --prod it will use 8 gigs instead of 2.
@jdpearce - Still seeing this issue after update to 8.9.0. I pushed the changes to the repo used to reproduce the scenario.
@vsavkin - I tried what you said but received an error
node --max-old-space-size=8192 ./node_modules/.bin/nx
C:\github\nx-example\node_modules\.bin\nx:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at Module._compile (internal/modules/cjs/loader.js:895:18)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11
I am on a windows machine running in git bash.
Also tried nx.cmd from command and nx.ps1 from powershell
I also tried setting an environment variable NODE_OPTIONS=--max-old-space-size=8192
but still no luck
If it helps I have two repos that both fail on spec 23, the test within the specs are completely different between the two repos. This also fails on our Jenkins server.
I also tested this with cypress 3.7.0 and still see the same issue and cypress still returns that all tests pass even though 2 tests assert false.
Cypress 3.4.1 also demonstrates the OOM issue but does summarize the test results correctly so that tests after OOM error report as failed.

We needed to update cypress to 3.6.1 because of this item
The Electron browser no longer hangs when testing applications that have a prompt in a beforeunload handler. Fixes https://github.com/cypress-io/cypress/issues/2118
3.6.1 summary

Unfortunately, we switched type checking back to being handled ts-loader instead of fork-ts-checker-plugin because it was causing cypress to hang when using a support file.
I believe this unintentional functionality but have not found a fix.
We probably need some assistance from the Cypress team to figure out what is going on here.
We are experiencing the same issue when running cypress in CI for our project, and were only able to resolve it by running our e2e tests in chunks, i.e. entirely isolated using a test name pattern. This seems to work fine so far, but comes with limitations (multiple test runs in cypress dashboard, decreased maintainability).
It would be amazing to see a final solution for this in the future.
Thanks for this awesome tool by the way! @FrozenPandaz
Unfortunately, we switched type checking back to being handled
ts-loaderinstead offork-ts-checker-pluginbecause it was causing cypress to hang when using a support file.
Would it be an idea to switch yet again? So move back to the fork-ts-checker-plugin as it does seem to reduce memory usage (by using a forked process). The issue that this sometimes was causing cypress to hang seems to be fairly easy to fix: https://github.com/nrwl/nx/issues/2063