Programming is bittersweet.
It is very tedious and many a time, it can leave developers very frustrated with little zeal for another keypress.
However, developers are always having a whale of a time while coding, and they are full of pride and joy, once all their codes run successfully without errors.
That being said no one wants to be frustrated while coding hence no one wants bugs in their codes.
Developers, often do not get it all right ("code-wise") at first try; consequently, the software development cycle involves debugging, refactoring, upgrading, and many other enhancement operations.
In addition, developers know that many a time we all have to deal with bugs in our code. Hence debugging is an invaluable skill in a developer's repertoire. And to be successful at debugging, we need a good understanding of error messages.
Error codes or messages are the ways computers inform us that there are bugs in our codes, and sometimes it tells us where they are.
The paradox is that error codes; although are very helpful, they are not plain English and can be very confusing and cryptic
Below are error codes from a crashed app on Heroku.
2019-10-11T11:27:28.019054+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=realtylabapp.herokuapp.com request_id=74165d9f-db2a-46bd-ab9c-1a01403bd00f fwd="129.205.113.108" dyno= connect= service= status=503 bytes= protocol=https
2019-10-11T11:27:29.919409+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=realtylabapp.herokuapp.com request_id=fa48efa2-4ddf-41e6-a633-a62cb02314bd fwd="129.205.113.108" dyno= connect= service= status=503 bytes= protocol=https
Heroku uses a unique alphanumeric error code combo to communicate to the developer the kind of error that was found in their code.
This alphanumeric error code ranges from:
H10toH99R10toR99L10toL15
Get a detailed list here: Complete Heroku Error Codes
This article is focused on the Heroku H10-App crashed error code which is thrown when an application crashes on Heroku. This is as much as it goes. It does not help us with the reason our app crashed and that's where this article comes in. Below are some causes of this error and I guarantee you that some of them would surprise you greatly!
-
Bug in Procfile
A very interesting discovery for me. A bug in your Procfile can crash your app. If your Procfile is pointing to the wrong server file. e.g If your server is in server.js and your Procfile points to app.js this would definitely crash your app and Heroku would greet you with the H10-App crashed error code message.
Secondly, a buggy Procfile can also come in the form of wrong spacing. e.g
Wrong: web : node index.js
Correct web: node index.js -
Setting a PORT as a Heroku environment variable
This would surely crash your app. Heroku automatically sets a Port that can be accessed viaprocess.env.PORT. Setting a port yourself would crash your app. Surprisingly, the commandheroku configdoes not display the preset Heroku port so one might be tempted to set another port as an environment variable.
To see all the preset Heroku environment variables, use the commandheroku run printenv. -
Missing Required Environment Variable while setting a port would cause this error because Heroku already sets a port internally, failing to set any required environment variable (e.g your database), would prompt Heroku to greet you with this error.
-
Missing Required Scripts
This error is thrown in a Node.js environment if you forget to set astart script. Heroku uses this script to start your app so if it is missing, it would throw anH10-App crashederror code message.
This can be solved by setting a start script in the package.json. e.g
"scripts": {
"start": "node index.js"
}
Final Thoughts
If none of the above solved your problem, you can make a last-ditch attempt by updating all your packages. If this doesn't help and you are in a Node.js environment, your last resort would be setting a node version in the engine section of your package.json file.
{
"name": "myapp",
"description": "a really cool app",
"version": "1.0.0",
"engines": {
"node": "12.11.1"
}
}
The Unthinkable
Lastly, if your bug defiles all solution, and by this time you are grasping at straws; I leave you in the able hands of heroku restart.
Let me know if you have experienced any other cause of this error in the comment below.

所有评论(0)