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:


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


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:

@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.


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:

1 Like