-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript Usage Results in Out of Memory Exception "JavaScript heap out of memory" #2316
Comments
I was able to reproduce this, but I don't believe this is a Cypress specific issue. The memory did not increase when I renamed all of the files to
This problem only exhibits itself when using Perhaps There may be some options in There may also be webpack specific options you can pass to prevent this from happening as well. Maybe someone on our team can look at this, but it seems this may not be an issue with Cypress. |
Thanks so much for looking into this. One thing that I've found that works is to pass the transpileOnly option to ts-loader. {
loader: "ts-loader",
options: {
transpileOnly: true
}
} Whatever ts-loader is hanging onto across tests, it doesn't do it when in transpileOnly mode; the memory used by Cypress Helper goes up and down as each test completes and starts up, always staying in the range of a couple hundred MB. |
That’s an excellent find!
…Sent from my iPhone
On Aug 11, 2018, at 21:46, Thomas Ladd ***@***.***> wrote:
Thanks so much for looking into this. One thing that I've found that works is to pass the transpileOnly option to ts-loader.
{
loader: "ts-loader",
options: {
transpileOnly: true
}
}
Whatever ts-loader is hanging onto across tests, it doesn't do it when in transpileOnly mode; the memory used by Cypress Helper goes up and down as each test completes and starts up, always staying in the range of a couple hundred MB.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Just an update on this, I tried updating to the latest ts-loader (v5.2.1), and even with the transpileOnly flag turned on, I end up running out of memory. Reverted back to 4.4.2 and not having issues. |
I was debugging why a seemingly-random set of our specs were failing with We are using Since we are using the "TypeScript with WebPack" example recipe as-is, this just meant adding the option use: [{
loader: 'ts-loader',
options: {
transpileOnly: true
}
}] |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
More specifically, ts-loader does have a section in their docs for optimizing faster builds here: https://github.com/TypeStrong/ts-loader#faster-builds |
My setup is: // package.json
"fork-ts-checker-webpack-plugin": "1.4.3",
"ts-loader": "5.3.0", // webpack.config
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
module.exports = {
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /\.ts$/,
exclude: [/node_modules/],
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
configFile: 'cypress/tsconfig.json',
},
},
],
},
],
},
plugins: [
new ForkTsCheckerWebpackPlugin({
tsconfig: './cypress/tsconfig.json',
}),
],
}; and the problem is gone as well. |
implements solution from github.com/cypress-io/cypress/issues/2316 Signed-off-by: Brenna Hewer-Darroch <brenna@chef.io>
implements solution from github.com/cypress-io/cypress/issues/2316 Signed-off-by: Brenna Hewer-Darroch <brenna@chef.io>
* move helpers and constants to support so cypress doesn't try to run tests in those files in CI * update ts-loader options implements solution from github.com/cypress-io/cypress/issues/2316 Signed-off-by: Brenna Hewer-Darroch <brenna@chef.io>
In my scenario when running my tests and running out of memory on spec 23 of 26 the testing continued to run even though no tests were actually being run and reported success even though the tests were not actually executed. Is this behavior correct? I would expect the remaining tests to fail. See screenshot below. Is this by design or should this be a bug? |
@JoA-MoS All of the spec files listed at the top of the run under |
@jennifer-shehane - I was able to repro this in a demo repo (https://github.com/JoA-MoS/nx-example/tree/cypress-js-heap-oom). I think the issue is that once the TypeScript Preprocessor hits the out of memory it no longer processes the tests written in typescript. I believe 3.4.1 failed after finishing all the tests where 3.6.1 states all specs passed. Here are the results of the demo repo specs 23 and 24 contain the following describe('demo-ui', () => {
beforeEach(() => cy.visit('/'));
it('I SHOULD NOT PASS', () => {
// Function helper example, see `../support/app.po.ts` file
cy.contains('THIS TEXT DOES NOT EXITS');
expect(false).to.be.true;
});
}); Spec 23 had the following logged to console.
Running the demo repo:
Related to: nrwl/nx#2103 |
* Update docs/submodules/vid.git from branch 'master' to 9364e31c8bc851b7543b0c16846dc6ef3ccf41c3 - Merge "cypress test - adding option transpileOnly: true" - cypress test - adding option transpileOnly: true See cypress-io/cypress#2316 (comment) Issue-ID: VID-732 Signed-off-by: Eylon Malin <eylon.malin@intl.att.com> Change-Id: I2aa21c1ef092b5caf5753402555e8e2eb19132b4
See cypress-io/cypress#2316 (comment) Issue-ID: VID-732 Signed-off-by: Eylon Malin <eylon.malin@intl.att.com> Change-Id: I2aa21c1ef092b5caf5753402555e8e2eb19132b4
* Chore: Upgrades Cypress to 8.4.1 * Update typescriptPreprocessor.js Found this cypress-io/cypress#2316
Current behavior:
When I try to use Typescript with Cypress, Cypress Helper's memory usage quickly scales up with the number of test files. The actual number of tests does not seem to be particularly important (i.e. it's fine to have 1 file with 100 tests in it, but 50 test files with 1 test each will break). After Cypress Helper's memory usage gets to a little of 2 GB in Activity Monitor, the tests grind to a halt and eventually result in an Out of Memory exception.
Desired behavior:
When using Typescript, the memory usage remains similar to how it behaves when not using typescript.
Steps to reproduce:
I have a repo setup that illustrates the issue: https://github.com/TLadd/cypress-ts-memory-leak/tree/master
It's a repo that only contains a basic cypress setup with typescript and @cypress/webpack-preprocessor. It contains 50 test files, each with one test each
expect(1).to.eq(1);
. For me, runningcypress run
consistently results in an out of memory exception trying to run the 37th test.Versions
Cypress: 3.0.3
OS: MAC High Sierra 10.13.4
Browser: Default Electron or Chrome
The text was updated successfully, but these errors were encountered: