Build fails with "Error: spawn ENOMEM"

our angular 7 builds randomly fails with “Error: spawn ENOMEM”
It happened a while back (every build), and our solution at the time was to increase memory with node --max_old_space_size=4096, which worked great, until now.
recently, it starts to fail again at random, with the same error. and a rebuild (without any code changes) fixes the problem.

i’ve tried to follow the recommendations listed on Caching Dependencies, but it doesn’t solve the issue.

the last failed circle build: https://circleci.com/gh/capehq/cloud-frontend/3042

====

to add, builds are more likely to fail when there are 2 builds happening at the same time.

3 Likes

same problem here

@jenCape is it still happening for you? This error is becoming more often during the last 2 weeks.

yes, it used to happen roughly every 3 or 4 builds
but starting today, it happens every build (so far) & really blocks developing :frowning:

Hey Jen, if you are getting this error in webpack.

We fixed it disabling multi-process parallel mode using terser-webpack-plugin.

And maybe, this issue also can help you: https://github.com/facebook/create-react-app/issues/6974

@davidsonfellipe thank you for the suggestion. unfortunately, we are using angular cli.
though your suggestion gave me an insight to look into our build settings. since we only ever experience this memory issue on dev (where source-map is enabled), i’ve decided to turn-off “buildOptimizer”.
So far, this seems to be working - will update if it begins to fail again though.

2 Likes

There is a jest flag that controls the number of processes spawned during testing. I changed my test command in config.yml from yarn test to yarn test --maxWorkers=2 and the process bottleneck disappeared.

I read it here first: https://vgpena.github.io/jest-circleci/

1 Like