Skip to content
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

cypress test is always crashes because of the memory issue. #30988

Open
pobox9918 opened this issue Jan 30, 2025 · 2 comments
Open

cypress test is always crashes because of the memory issue. #30988

pobox9918 opened this issue Jan 30, 2025 · 2 comments
Labels

Comments

@pobox9918
Copy link

pobox9918 commented Jan 30, 2025

there seems memory issue with Cypress (tried with 13.17.0 and 14.0.0)

  1. I am using node JS with Cypress on test automation, to use npx cypress open to run the e2e test, but I the browser crashes at the JS VM heap size around 2GB. (it maybe node.js default memory limit is 2GB (for 64bit and 1.4GB for 32). I tried to configure the limit to 8GB by following ways:
  2. in package.js, script block, use "test": "NODE_OPTIONS='--max-old-space-size=8192' npx cypress run", or "test": "NODE_OPTIONS='--max-old-space-size=8192' npx cypress open", (since I run my test by npx cypress open, then start e2e test).
  3. in my cypress.config.js file, I tried to use:
e2e: {
    setupNodeEvents(on, config) {
      on('before:browser:launch', (browser = {}, launchOptions) => {
          if (browser.name === 'chrome' || browser.name === 'edge') {
            launchOptions.args.push('--js-flags=--max-old-space-size=9000'); // Adjust MB size as needed
            launchOptions.args.push('--disable-dev-shm-usage');
            launchOptions.args.push('--js-flags=--expose-gc');
            launchOptions.args.push(
              '--disable-gpu',
              '--disable-background-timer-throttling',
              '--disable-renderer-backgrounding',
              '--disable-backgrounding-occluded-windows'
            );
          }
          return launchOptions;  /// } should not put here, seems the launchOptions not returned to use 
        });
      ... 

but with all above ways, the browser still crashes by the JS VM instance heap size reaches the default 2GB limit.
2) after the test run, the memory for JS VM instance heapsize does not drop much although we used all possible ways to limit the memory usage. It indicates there are memory leaks in current Cypress.

@pobox9918
Copy link
Author

I am working for IBM, and we chose to use Cypress for our automation framework since last year. I heard other team members got the memory leak and browser crashes as well. The error message is:

DevTools listening on ws://127.0.0.1:52142/devtools/browser/a3519c68-6998-4949-a574-5c4009ef121a
2025-01-30 15:16:05.075 Cypress[72360:1484147] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
We detected that the Chrome Renderer process just crashed.

We have failed the current spec but will continue running the next spec.

This can happen for a number of different reasons.

If you're running lots of tests on a memory intense application.

  • Try increasing the CPU/memory on the machine you're running on.
  • Try enabling experimentalMemoryManagement in your config file.
  • Try lowering numTestsKeptInMemory in your config file during 'cypress open'.

You can learn more here:

https://on.cypress.io/renderer-process-crashed
We detected that the Chrome tab running Cypress tests closed unexpectedly.

We have failed the current spec and aborted the run.
larryshen@Lirens-MacBook-Pro wxo-uab-cypress %

@pobox9918
Copy link
Author

I've already verified both node js and chrome browser are set to 8GB for memory limit. But the test crashes the same once it reached the default memory limit (2GB)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants