create-react-app: [Bug] CircleCI + Terser Error: Call retries were exceeded
Bug
When you use CircleCI to build the project, it will sometimes not compile throwing the error below.
Looks like this is a known problem here: https://github.com/webpack-contrib/terser-webpack-plugin/issues/143#issuecomment-573954013. Recommend setting the webpack configuration based on the feedback.
#!/bin/bash -eo pipefail
yarn build
yarn run v1.21.1
$ react-scripts build
Creating an optimized production build...
Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
Failed to compile.
Failed to minify the bundle. Error: static/js/1.dc6042b5.chunk.js from Terser
Error: Call retries were exceeded
at /home/circleci/project/node_modules/react-scripts/scripts/build.js:196:23
at finalCallback (/home/circleci/project/node_modules/webpack/lib/Compiler.js:257:39)
at /home/circleci/project/node_modules/webpack/lib/Compiler.js:273:13
at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/circleci/project/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:22:1)
at AsyncSeriesHook.lazyCompileHook (/home/circleci/project/node_modules/tapable/lib/Hook.js:154:20)
at onCompiled (/home/circleci/project/node_modules/webpack/lib/Compiler.js:271:21)
at /home/circleci/project/node_modules/webpack/lib/Compiler.js:681:15
at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/circleci/project/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
at AsyncSeriesHook.lazyCompileHook (/home/circleci/project/node_modules/tapable/lib/Hook.js:154:20)
at /home/circleci/project/node_modules/webpack/lib/Compiler.js:678:31
at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/circleci/project/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
at AsyncSeriesHook.lazyCompileHook (/home/circleci/project/node_modules/tapable/lib/Hook.js:154:20)
at /home/circleci/project/node_modules/webpack/lib/Compilation.js:1423:35
at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/circleci/project/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
at AsyncSeriesHook.lazyCompileHook (/home/circleci/project/node_modules/tapable/lib/Hook.js:154:20)
at /home/circleci/project/node_modules/webpack/lib/Compilation.js:1414:32
Read more here: https://bit.ly/CRA-build-minify
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Exited with code exit status 1
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 90
- Comments: 50 (8 by maintainers)
Commits related to this issue
- ci: fix terser resource problem https://github.com/facebook/create-react-app/issues/8320#issuecomment-623201931 — committed to Conflux-Chain/sirius by yqrashawn 3 years ago
- react scripts 4.02 — committed to beyondessential/tupaia by tcaiger 3 years ago
- add terser webpack plugin to fix failed deploys see: https://github.com/facebook/create-react-app/issues/8320#issuecomment-822142301 — committed to ademidun/atila-client-web-app by ademidun 3 years ago
- add terser package to fix failed deploys see: https://github.com/facebook/create-react-app/issues/8320#issuecomment-822142301 — committed to ademidun/atila-client-web-app by ademidun 3 years ago
- increase memory capacity to fix failed builds see: https://github.com/facebook/create-react-app/issues/8320#issuecomment-625168957 — committed to ademidun/atila-client-web-app by ademidun 3 years ago
Activity
I think that this issue still exists.
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.
I was able to get around the
Error: Call retries were exceeded
error by increasing the instance type for the job in the circleci yaml config by addingresource_class: large
. I think the error occurs when the build requires more memory than what the circleci instance allows..circleci/config.yml
The craco workaround posted in the above comments did not work for me.
@stalebot take a holiday mate
I don’t think that this issue should be closed. We’re still having to use craco to have insight into the Terser config and parallel setting
@kyeotic this was a hacky approach that worked for us
I see here https://github.com/facebook/create-react-app/pull/6732/files that similar problem was fixed specifically for single use case. Why not fixing this for everybody ? Seems lot of build pipelines are very unstable because of Terser. We also have issues with running build on Circle CI.
@christophehurpeau advised adding option to configure this. I believe this would solve a lot of problems with builds instabbility.
I was having the same issue on AWS Amplify, and wanted to find a solution other than updating the Webpack configuration. Resolving the
terser-webpack-plugin
to the latest version did the trick for me without any build errors (even though I jumped two major versions with this change):Having the same issue on circle ci
Please do not close. It’s still an open issue.
I am using similar workaround as above, just by using
react-app-rewired
and having this loop to alter config:Would be good to have this CPU detection fixed properly, alternatively having option to turn OFF parallelization.
Forcing
terser-webpack-plugin
to a more recent version seems to have solved this issue for me. Thanks @sammarks.If I’m not mistaken this is mainly due to this fix, so any version newer than 2.3.3 would do. (react-scripts@4.0.3 uses webpack@4.44.2 which has a dependency on terser-webpack-plugin@1.4.3.)
So to solve this issue, all that has to be changed is to update dependencies. I guess it’s tracked in #9994.
Just a note - the Craco solution works well for this issue, but be aware that the config above turns off
sourceMap
- which you may want to enable for your production build.A quick fix would be having an environment variable for setting the parallel configuration option.
Issue opened since January! This needs to be fixed
We encountered the same issue on our own GitLab instance, increasing CPU and memory limits of the CI containers solved it. This solution only works if you host the CI by yourself, though.
This finally worked for me! This is simpler than using craco or the equivalent. Thank you for saving me from going insane … Thanks to @graup and @sammarks
if anyone find this issue by google, please check the memory usage during npm run build
@hernanif1 my best guess is that suspense (ie code splitting) is the root cause of this. we started seeing failures on CI after code splitting, and on revert, with everything else staying the same, the issue did not show up. the nice part of the workaround is that we are able to continue to use code splitting
Yeah, this is still and issue for me as it’s hapenning also with Bitbucket Pipelines and CRA.
Quick update, the workaround for now is setting explicitly
parallel
option.https://github.com/webpack-contrib/terser-webpack-plugin#parallel
Explanation: https://github.com/webpack-contrib/terser-webpack-plugin/issues/202#issuecomment-580704210
@hernanif1 Maybe you could try and configure terser in a such way: https://auth0.com/blog/how-to-configure-create-react-app/ (from https://create-react-app.dev/docs/alternatives-to-ejecting)
@ebwittenberg
According to docs, that disables parallel running (it is the same as False):
https://github.com/webpack-contrib/terser-webpack-plugin#parallel
By default the parallel is calculated based on number of available cpus, but since CircleCi doesn’t provide a reliable value for this, this usually explodes memory usage (because the number of instances/parallel is too high).
One workaround is to setting this value by hand (and not relying on CircleCi fake cpu count), but for this you need better machines (not the free ones).
The other option is disabling parallel. (In my case, I didn’t need to have a more expensive machine). It may be a little bit slower but it was cheaper .
@onilton this worked for me, but what is it doing when
item.options.parallel
is set to 0? It seems that other solutions involve increasing the number of parallel processes.“me too” comments are noise. A hack-solution was posted above, but the problem remains. Asking if it has been solved to keep the issue active is one thing, but that was done 9 days ago. The addition of a stack trace and your config is just more confirmation that you are experiencing the issue. Its not helpful though, nobody is arguing that the issue exists so there is nobody to convince. Your post isn’t adding any value, only people subscribed to this thread will see it and its already active. “me too” is just noise.
If you want to raise the attention of the issue upvote/emoji-react the first comment so that it sorts higher on the issue page.
Does anyone have solutions to this issue yet?
Package config. “terser-webpack-plugin”: “^2.3.5”, “webpack”: “^4.42.0”,
webpack config-
Stopping by to note that I experienced this issue when upgrading react from
16.12.0
to16.13.0
(an upgrade which included version updates ofterser
&terser-webpack-plugin
in myyarn.lock
file).The craco solution is the way to go for this issue at the moment. Thanks to everyone that contributed above, this was doing my head in.