razzle: Slow build time makes Heroku deployment to fail
Hi Jared,
I just tried to deploy an app I’ve been working on for the last month to Heroku. After deploying I got the following errors:
2016-06-08T15:20:14.906386+00:00 app[web.1]: > npm run clean && npm run build && cross-env NODE_ENV=production node ./build/server
2016-06-08T15:20:14.906349+00:00 app[web.1]:
2016-06-08T15:20:16.312074+00:00 app[web.1]: > rm -rf build
2016-06-08T15:20:16.312075+00:00 app[web.1]:
2016-06-08T15:20:17.182897+00:00 app[web.1]: > react-production-starter@0.1.0 build /app
2016-06-08T15:20:17.182898+00:00 app[web.1]: > webpack -p --config ./webpack.config.prod.js && webpack -p --config ./webpack.server.config.prod.js
2016-06-08T15:20:17.182899+00:00 app[web.1]:
2016-06-08T15:21:12.058454+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-06-08T15:21:12.058454+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-06-08T15:21:13.159176+00:00 heroku[web.1]: Process exited with status 137
2016-06-08T15:21:13.174340+00:00 heroku[web.1]: State changed from starting to crashed
It looks like the build script takes more then 60 seconds which make Heroku think it failed.
I guess that I could run the build locally and commit the files and skip building altogether but I wonder if there’s a better way?
Any suggestions?
Thanks!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (4 by maintainers)
Commits related to this issue
- server - attempted to fix build timeout on heroku, according to https://github.com/jaredpalmer/razzle/issues/68 FreeCodeCamp - Dynamic Web Application Projects - Chart the Stock Market — committed to htbkoo/ChartTheStockMarket by htbkoo 7 years ago
- server - attempted to fix build timeout on heroku, according to https://github.com/jaredpalmer/razzle/issues/68 FreeCodeCamp - Dynamic Web Application Projects - Chart the Stock Market — committed to htbkoo/ChartTheStockMarket by htbkoo 7 years ago
- To solve timeout issue on Heroku, using `heroku-postbuild` https://github.com/jaredpalmer/razzle/issues/68 [skip ci] — committed to ridi/simple-service-status by deleted user 6 years ago
@ranyefet This is a rather old issue, but I just want to add a point in addition to the other solutions suggested here. I ran into this problem lately and weren’t able to solve things by specifying listening port to process.env.PORT like most people suggested, or removing packages from build dependencies (I do need all the packages!)
So in the end I figured out by adding the npm run build, or webpack -p, whatever you are using to build the project, into the post-install scripts inside package.json.
for example, this can be your package.json’s script field:
By doing this heroku will attempt to build the project after you have pushed the code to heroku server, but before it enforces the 60 seconds timeout.
You do not need to build things locally, add them to git repo, and push.
@ctrlplusb sweet, i actually just found this:
"heroku-postbuild": "npm run build"https://devcenter.heroku.com/articles/nodejs-support#customizing-the-build-process
worked like a charm.
You could run the “build” step concurrently with “start” rather than before it. That way you bind to the $PORT before your assets are completely built.
You have to be okay with the possibility of someone visiting your app in the minute or so before the assets are ready.