adamreisnz / replace-in-file

A simple utility to quickly replace contents in one or more files
580 stars 65 forks source link

Add bottleneck to rate limit Promise.all so that it can handle a larg… #131

Closed stefl closed 2 years ago

stefl commented 4 years ago

Thanks for a really helpful library! I'm using it on a deployment process that needs to swap out strings in around 10,000 files during build. On certain glob matches, this causes a failure, because Promise.all attempts to run all promises concurrently. Node fails with a memory error. This change introduces a rate-limit to Promise.all and ensures that only 5 replacement processes are running concurrently. 5 is an arbitrary number, but seems reasonable. I've verified this causes no test failures, and it results in my build process completing. However, it introduces a dependency, so you may want to take this as a helpful pointer but make your own version of what Bottleneck does.

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling e51fdd6d683f240ad000d3f69ea2d26bf1e5d1e5 on stefl:master into ebb3c7df191189fc8d3d7bb43797c91994d75096 on adamreisnz:master.