Resolving "Failed to minify the bundle" Errors

The following error message is usually related to running out of memory during a job:

Failed to minify the bundle. Error: static/js/12.fb78ba11.chunk.js from Terser
Error: Call retries were exceeded

Webpack4 starts using terser-webpack-plugin to minify your JavaScript as default. The default parallel option in terser-webpack-plugin is set to the number of CPUs (os.cpus().length - 1). It means the function references the actual VM's CPU count, and it's a bigger number of CPUs than the docker executor has. Therefore, Webpack will make more workers than the vCPU counts, and it causes this error.


To work around this, you will need to specify the parallel option to set to the same number as the vCPUs. For example:

const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
  optimization: {
    minimizer: [
      new TerserPlugin({
        parallel: 2,
      }),
    ],
  }
};

More information about this can be found at the links below:

https://webpack.js.org/configuration/optimization/#optimizationminimizer
https://webpack.js.org/plugins/terser-webpack-plugin/#parallel

 

If it doesn't solve the problem, there are a couple of options you can try:

For additional visibility on memory usage issues, consider logging the maximum memory usage for the job.

Was this article helpful?
1 out of 1 found this helpful

Comments

0 comments

Article is closed for comments.