0

I can't figure out what is the problem with heroku, I've spent 2 days trying to figure out what this error means to no avail.

2021-07-18T04:27:08.741998+00:00 app[web.1]: {"level":30,"time":1626582428741,"pid":44,"hostname":"98a3475f-ac16-4dfa-91e0-46d53d3b5e4c","msg":"Server listening at http://127.0.0.1:34196"}

Server is running as you can see, but when i tried to access my app from the web. This happens..

2021-07-18T04:27:56.941807+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

I have no clue what the problem is. My app is clearly running on the intended PORT as Heroku assigned it to be.

package.json

"scripts": {
"test": "npm run build:ts && tsc -p test/tsconfig.test.json && cross-env TS_NODE_FILES=true tap --ts test/**/*.test.ts",
"start": "npm run build:ts && fastify start -l info dist/app.js",
"build:ts": "tsc",
"dev": "tsc && concurrently -k -p \"[{name}]\" -n \"TypeScript,App\" -c \"yellow.bold,cyan.bold\" \"tsc -w\" \"fastify start --ignore-watch=.ts$ -w -l info -P dist/app.js\"",
"database": "npx prisma migrate dev && npx prisma db seed --preview-feature" },

here's the log from heroku logs --tail

2021-07-19T04:34:45.411610+00:00 heroku[web.1]: Stopping process with SIGKILL
2021-07-19T04:34:45.535520+00:00 heroku[web.1]: Process exited with status 137
2021-07-19T04:34:45.641077+00:00 heroku[web.1]: State changed from starting to crashed
2021-07-19T04:34:45.648836+00:00 heroku[web.1]: State changed from crashed to starting
2021-07-19T04:34:59.197914+00:00 heroku[web.1]: Starting process with command `npm start`
2021-07-19T04:35:02.499184+00:00 app[web.1]:
2021-07-19T04:35:02.499211+00:00 app[web.1]: > app@1.0.0 start /app
2021-07-19T04:35:02.499211+00:00 app[web.1]: > fastify start -l info dist/app.js
2021-07-19T04:35:02.499212+00:00 app[web.1]:
2021-07-19T04:35:03.830676+00:00 app[web.1]: {"level":40,"time":1626669303829,"pid":21,"hostname":"5b062824-4105-40ff-87b7-5846163fdac5","msg":"Allowing all origins"}
2021-07-19T04:35:03.856136+00:00 app[web.1]: {"level":40,"time":1626669303855,"pid":21,"hostname":"5b062824-4105-40ff-87b7-5846163fdac5","msg":"\"root\" path \"/app/assets\" must exist"}
2021-07-19T04:35:05.924577+00:00 app[web.1]: {"level":30,"time":1626669305924,"pid":21,"hostname":"5b062824-4105-40ff-87b7-5846163fdac5","msg":"Server listening at http://127.0.0.1:42948"}
2021-07-19T04:35:59.304046+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2021-07-19T04:35:59.382557+00:00 heroku[web.1]: Stopping process with SIGKILL
2021-07-19T04:35:59.486461+00:00 heroku[web.1]: Process exited with status 137
2021-07-19T04:35:59.559137+00:00 heroku[web.1]: State changed from starting to crashed

Notice the app ran just fine, but after a while heroku just stopped working indicated from heroku[web.1] after the app started, which is app[web.1]

  • Maybe you run something before call listen function, and it take too many time (>60s) – hong4rc Jul 18 '21 at 05:22
  • That could be the case, but I think fastify have their listen function after all my code has been run. So if it hangs somewhere, my app wouldn't print out the "msg":"Server listening at http://127.0.0.1:34196"} –  Jul 18 '21 at 05:55
  • You can see the message but how long after your app start, do you build anything? If the answer is yes, please me build in build script in `package.json` – hong4rc Jul 18 '21 at 06:06
  • I have my app started in my local machine almost instantly, the build script is basically calling node on the main function of my app, since you can't really build and compile apps in javascript, unlike go or rust.. or maybe any other language @.@ I have updated my post so you can see what is in the scripts in my package.json –  Jul 18 '21 at 06:15

2 Answers2

1

You call tsc and it take along time to build.

Change build:ts to build and remove npm run build:ts in start script:

Document here

{
    "name": "something",
    "others key": "here",
    "scripts": {
        "start":"fastify start -l info dist/app.js",
        "build": "tsc",
        "others script":"echo 'others'",
    }
}
hong4rc
  • 3,999
  • 4
  • 21
  • 40
  • i changed my scripts, unfortunately the problem still persists –  Jul 18 '21 at 17:17
  • Can you upload a file with your log here – hong4rc Jul 19 '21 at 03:19
  • essentially, what heroku logs --tail outputs are only those two lines in my post. It kept restarting until heroku decided not to by itself –  Jul 19 '21 at 04:40
0

Heroku can only accept applications that's running on 0.0.0.0:{whatever port they assign}. My Fasitfy app was running on 127.0.0.1, which is not the same as 0.0.0.0 apparently. Nevertheless, Heroku doesn't accept any port other than 0.0.0.0