Allow customising memory limits for Cypress workers for lower memory CI instances.
See original GitHub issueDescription
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:
- Created 2 years ago
- Reactions:1
- Comments:17 (10 by maintainers)
I have some great news π β¦ nx version
12.6.0-beta.6
came out yesterday and I did the migration today. now version6.2.1
offork-ts-checker-webpack-plugin
is used, and I was able to set the memory limit like I tried before (using cosmiconfig) atpackage.json
:I added a
console.log
at my local\node_modules\fork-ts-checker-webpack-plugin\lib\ForkTsCheckerWebpackPlugin.js
to verify that thememoryLimit
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 version12.6.0-beta.6
of nx (but be aware, the option will be considered for each instance ofForkTsCheckerWebpackPlugin
if you use this workaround) π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!