question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow customising memory limits for Cypress workers for lower memory CI instances.

See original GitHub issue

Description

I would like to be able to reduce the amount of memory workers take when using the plugin. At the moment, when I run nx run myapp:e2e it prints Using 1 worker with 2048MB memory limit.

- Generating browser application bundles (phase: setup)...
[...]
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
βœ” Compiled successfully.
[...]
====================================================================================================

  (Run Starting)

  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ Cypress:    7.5.0                                                                              β”‚
  β”‚ Browser:    Electron 89 (headless)                                                             β”‚
  β”‚ Specs:      3 found (modules/login/login/login-logout-redirect.spec.ts, modules/login/login/lo β”‚
  β”‚             gin.spec.ts, modules/login/logout/logout.spec.ts)                                  β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜


────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                    
  Running:  modules/login/login/login-logout-redirect.spec.ts                               (1 of 3)
Starting type checking service...
Using 1 worker with 2048MB memory limit
Starting type checking service...
Using 1 worker with 2048MB memory limit
  • I would like to make each worker take 1024MB instead of 2048

Motivation

That way we could have users run their Cypress CI processes on lower memory instances.

I am running a GitLab Runner with 1 GB of RAM configured with 1 GB of swap space (AWS T3 Micro).

Suggested Implementation

For that to work we would need to tap into ForkTsCheckerWebpackPlugin’s constructor in order to inject the memoryLimit option with Nx.

Here’s the relevant file: https://github.com/nrwl/nx/blob/12.5.7/packages/cypress/src/plugins/preprocessor.ts#L53

      new ForkTsCheckerWebpackPlugin({
        tsconfig: config.env.tsConfig,
        useTypescriptIncrementalApi: false,
        ...suggestingDesigningSomeConfigurationObjectThatCanGetExpandedHere // <------- Customisable object!
      }),

So that way I could pipe the memoryLimit there as:

suggestingDesigningSomeConfigurationObjectThatCanGetExpandedHere = { memoryLimit: 1024 }; // <----- Customisable object!

Alternate Implementations

Maybe we could only target that memoryLimit option, since more people that are running pipelines on budget could have end to end CI without running out of memory or crashing the instance.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
skydevercommented, Jul 14, 2021

I have some great news πŸ˜„ … nx version 12.6.0-beta.6 came out yesterday and I did the migration today. now version 6.2.1 of fork-ts-checker-webpack-plugin is used, and I was able to set the memory limit like I tried before (using cosmiconfig) at package.json:

  "fork-ts-checker": {
    "typescript": {
      "memoryLimit": 8000
    }
  }

I added a console.log at my local \node_modules\fork-ts-checker-webpack-plugin\lib\ForkTsCheckerWebpackPlugin.js to verify that the memoryLimit will be used, and I got the expected output - and now my tests passed, no out of memory error πŸŽ‰

To sum up - memoryLimit should be added to the cypress config of nx to avoid the temp. workaround using cosmiconfig that is possible with version 12.6.0-beta.6 of nx (but be aware, the option will be considered for each instance of ForkTsCheckerWebpackPlugin if you use this workaround) πŸ‘

1reaction
barbados-clemenscommented, Feb 18, 2022

Hi there, have y’all tried updating to the latest version of cypress or something > 7, as the preprocessor plugin isn’t needed. This will be removed in nx v14 as well. Let me know if it’s still an issue. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cypress soaking up all available memory - Stack Overflow
I'm having serious issues with Cypress soaking up all my available memory (16Gb). I have 30+ tests and if I attempt to run...
Read more >
How Can I Increase the Max Memory for Node?
Default Memory Size Node has a default max memory usage of less than 2GB on some 64bit systems (depending on the Node runtime...
Read more >
Configure memory limits | Cloud Run Documentation
This page describes how to set memory limits. Understanding memory usage. Cloud Run container instances that exceed their allowed memory limit areΒ ...
Read more >
Best Practices - Cypress Documentation
The Real World App (RWA) uses two useful custom commands for selecting elements for testing: getBySel yields elements with a data-test attribute that...
Read more >
Creating and Modifying Quota Plans | Cloud Foundry Docs
Default Quota Plan for an Org Β· Memory limit: 10240Β MB Β· Total routes: 1000 Β· Total services: 100 Β· Non-basic aervices allowed: true...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found