[Discord.js] [Heroku] Bot crashes every several minutes after deployment.

Hello, everyone!

I’m seeking help for my Discord bot because it crashes every time when I deploy it to Heroku. Here’s the log so you can understand what I’m talking about.

2020-05-07T07:15:05.000000+00:00 app[api]: Build succeeded
2020-05-07T07:15:09.157704+00:00 app[web.1]: 
2020-05-07T07:15:09.157729+00:00 app[web.1]: > edinburgh@1.0.0 start /app
2020-05-07T07:15:09.157729+00:00 app[web.1]: > node .
2020-05-07T07:15:09.157730+00:00 app[web.1]: 
2020-05-07T07:15:09.819548+00:00 app[web.1]: Edinburgh is ready to go.
2020-05-07T07:17:10.318495+00:00 heroku[web.1]: State changed from starting to crashed

There’s no error at my index.js, all of them are ready to be launched. I tried to deploy my bot through my PC and it’s all fine… But you know, I want to open my bot 24/7. Which is why I picked Heroku.

Your help will be very much appreciated. If you like to look at my Discord bot files, you can visit this GitHub link: https://github.com/sccooottttie/Edinburgh

1 Like

Your Procfile is using worker but in your console, it seems that the web dyno is being invoked instead. In your Resources tab, does it list web or worker process type?

I suspect it’s because you named your Procfile as Procfile.txt and not Procfile. According to Heroku’s doc:

Procfile naming and location

The Procfile is always a simple text file that is named Procfile without a file extension . For example, Procfile.txt is not valid.

The Procfile must live in your app’s root directory. It does not function if placed anywhere else.

1 Like

Yes, in my Resources tab, it’s listed web.
And thanks for telling me about the use of Procfile. I’ll remove the file extension and deploy it once again.

1 Like

Update, it’s still happening again but it’s now looked like this:

2020-05-07T11:06:18.095365+00:00 app[api]: Deploy c5a1b5bf by user
2020-05-07T11:06:18.000000+00:00 app[api]: Build succeeded
2020-05-07T11:06:18.095365+00:00 app[api]: Release v34 created by user
2020-05-07T11:06:24.512152+00:00 app[web.1]: Edinburgh is ready to go.
2020-05-07T11:07:21.131645+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-07T11:07:21.135631+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-07T11:07:25.976542+00:00 app[web.1]: Edinburgh is ready to go.
2020-05-07T11:08:23.563411+00:00 heroku[web.1]: State changed from starting to crashed

It crashes the first time and runs up again, and it crashes for the second time.

What does it look like in your Resources tab?

Is it still running web dyno?

1 Like

Yes, it’s enabled.

Web node index.js

It’s still using web dyno I guess. Maybe try disabling it and enable the worker dyno instead.

1 Like

Wait, is there supposed to have two dynos?

I think it’s not crashing now… Here’s the log looks like after I enabled worker dyno.

2020-05-07T12:23:59.520884+00:00 app[api]: Release v39 created by user
2020-05-07T12:24:00.000000+00:00 app[api]: Build succeeded
2020-05-07T12:24:03.182300+00:00 heroku[worker.1]: State changed from starting to up
2020-05-07T12:24:05.547762+00:00 app[worker.1]: Edinburgh is ready to go.

I think we’re good?

1 Like

My mistake. It should be process type.

I think so.

If you’re using the free dyno, you only have 550 free dyno hours (1000 if you have a verified credit card). It should be fine if you only have 1 free dyno running.

1 Like

Well it seems it’s not crashing anymore…

1 Like

That’s good then.

Keep up the good work.

1 Like

So it will stay online if I only have one dyno running?

1 Like

Thanks for help mate, I really appreciate it and I’m really glad I found this forum. : )

1 Like

If it’s 550 hours and 1 free dyno, maybe not.

550/24 = 22.9 days or so.

If it’s 1000 hours (with credit card) and 1 free dyno, maybe.

1000/24 = 41.6 days or so.

Reference

This is the case for worker process type dyno. web is probably different because free dyno doesn’t run web process 24/7.

1 Like

No worries.

Feel free to ask more questions in the future. There is a lot of people here who are far far more knowledgeable than me.

1 Like

Thanks for the info!