Recurring Logentries crash notification on Heroku (NodeJS server) - node.js

I've running a NodeJS-based application server on Heroku, and this morning it started crashing repeatedly. It runs one traditional 1x dyno (i.e. the free tier). Heroku takes it down due to idleness, which is fine, but it then gets into a state where I get a crash notification from Logentries every few seconds indefinitely.
I can stop it by taking manually taking the server down to 0 dynos, and then back up to 1.
Note that the very first thing the server does is print a debugging message to console.log, so the fact that I'm not seeing that in the middle of all these crash messages suggests that my app isn't even being run.
Any idea what might be causing this?
02 <45>1 2015-12-05T21:03:30.039646+00:00 heroku web.1 - - Idling
125 <45>1 2015-12-05T21:03:30.040156+00:00 heroku web.1 - - State changed from up to down
131 <45>1 2015-12-05T21:03:34.298780+00:00 heroku web.1 - - Stopping all processes with SIGTERM
301 <158>1 2015-12-05T21:03:35.730386+00:00 heroku router - - at=info method=GET path="/" host=<server name redacted>.herokuapp.com request_id=e3c6cdbf-3012-4e5e-ab89-24e8c2eb0e03 fwd="50.0.151.247" dyno=web.1 connect=0ms service=2085875ms status=101 bytes=189
310 <158>1 2015-12-05T21:03:36.299732+00:00 heroku router - - at=error code=H10 desc="App crashed" method=GET path="/" host=<server name redacted>.herokuapp.com request_id=35c719d9-5153-49e8-a640-91f848f853b9 fwd="50.0.151.247" dyno= connect= service= status=503 bytes=
310 <158>1 2015-12-05T21:03:36.730513+00:00 heroku router - - at=error code=H10 desc="App crashed" method=GET path="/" host=<server name redacted>.herokuapp.com request_id=138f048e-4229-4e9f-9e56-8d0d9e691734 fwd="50.0.151.247" dyno= connect= service= status=503 bytes=
126 <45>1 2015-12-05T21:03:36.690366+00:00 heroku web.1 - - Process exited with status 143
310 <158>1 2015-12-05T21:03:40.160167+00:00 heroku router - - at=error code=H10 desc="App crashed" method=GET path="/" host=<server name redacted>.herokuapp.com request_id=0a451a1b-04f2-4f59-bc1e-abc1f2599607 fwd="50.0.151.247" dyno= connect= service= status=503 bytes=
310 <158>1 2015-12-05T21:03:40.586679+00:00 heroku router - - at=error code=H10 desc="App crashed" method=GET path="/" host=<server name redacted>.herokuapp.com request_id=c7681cce-f486-447b-9f76-b36a8db3570b fwd="50.0.151.247" dyno= connect= service= status=503 bytes=
310 <158>1 2015-12-05T21:03:44.024709+00:00 heroku router - - at=error code=H10 desc="App crashed" method=GET path="/" host=<server name redacted>.herokuapp.com request_id=ddd8187f-c8c7-45aa-8add-863b17bdfc5f fwd="50.0.151.247" dyno= connect= service= status=503 bytes=

It turned out that the version of node I was using (4.2.1) was attempting to use more than the 512MB of memory available on a traditional 1x dyno (this is why Node kept crashing before it executed even the first line of my server code). The solution was to modify the Procfile to cap Node's memory usage to fit into the available memory. The Procfile now looks like so:
web: node --optimize_for_size --max_old_space_size=500 --gc_interval=100 server.js
(note that it's 500 rather than 512 out of my habitual desire to be a wee bit conservative).

Related

Why Heroku app crashes following H10 and how to spot the problem?

I am deploying an app to node.js mongodb-Atlas hosted Heroku app and after deploying it, it started to crash. here is the log of the incident:
2019-11-07T14:03:44.54763+00:00 app[web.1]:
2019-11-07T14:03:44.547905+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-11-07T14:03:44.548078+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-11-07T14_03_43_920Z-debug.log
2019-11-07T14:03:44.609666+00:00 heroku[web.1]: Process exited with status 1
2019-11-07T14:03:44.660116+00:00 heroku[web.1]: State changed from starting to crashed
2019-11-07T14:08:46.771752+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=flix-app-test.herokuapp.com request_id=14978e4f-fb93-44c8-a6c1-294a6a254e1e fwd="84.17.61.226" dyno= connect= service= status=503 bytes= protocol=https
2019-11-07T14:08:47.381666+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=flix-app-test.herokuapp.com request_id=b067c4c5-8b09-44c7-907e-bb2010dd97ec fwd="84.17.61.226" dyno= connect= service= status=503 bytes= protocol=https
2019-11-07T14:15:51.61258+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=flix-app-test.herokuapp.com request_id=5290a4ea-94b1-4d79-a8fe-6709e6cb2a15 fwd="91.168.132.252" dyno= connect= service= status=503 bytes= protocol=https
2019-11-07T14:15:52.254787+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=flix-app-test.herokuapp.com request_id=41f76767-00c8-490c-9c13-22c0906fedb9 fwd="91.168.132.252" dyno= connect= service= status=503 bytes= protocol=https
Most posts I found regarding this H10 error point to an issue on the lines that define the port which through Heroku listens, that it does not accept a rigid one, but the listening of the app is done by this code:
var port = process.env.PORT || 3000;
app.listen(port, "0.0.0.0", function() {
console.log('Listening on Heroku defined port');
});
The code is working locally (double checked), but the Heroku app does not even loads. Databases are running and available and I could find no visible problem.
I'd like to know how should I proceed to find out which part of the code is broken OR to find out that it's a Heroku temporarily issue.
Thanks in advance.
If you are using ExpressJS, just do:
var port = process.env.PORT;
Promise.resolve(app.listen(port)).then(() => {
console.log("Running!");
});
Anyways, 503 is Service Unavailable HTTP code. If the above code does not work, please post your router and controller code for the errored routes.

State changed from up to crashed in Heroku

I am getting the following error on Heroku logs:
2018-10-29T00:48:34.198959+00:00 heroku[reminder.1]: State changed from up to crashed
2018-10-29T00:48:59.855673+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=promo-reminder.herokuapp.com request_id=253b5e26-384e-4b02-b65c-51342fb46a4e fwd="73.162.11.10" dyno= connect= service= status=503 bytes= protocol=https
2018-10-29T00:49:01.143244+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=promo-reminder.herokuapp.com request_id=b1b8cb23-01d8-4f59-ac42-a98f28cb9c10 fwd="73.162.11.10" dyno= connect= service= status=503 bytes= protocol=https
2018-10-29T00:56:23.879027+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=promo-reminder.herokuapp.com request_id=00c30077-8e31-4fea-a700-f7fffd45e446 fwd="73.162.11.10" dyno= connect= service= status=503 bytes= protocol=https
2018-10-29T00:56:25.162371+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=promo-reminder.herokuapp.com request_id=1684c085-7c4a-4f90-beed-a6667c60ab88 fwd="73.162.11.10" dyno= connect= service= status=503 bytes= protocol=https
my Procfile is:
reminder: python src/quickstart.py
Heroku web page shows:
Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail
Only the web process type on Heroku will allow you to receive HTTP requests.
You need to replace your Procfile:
reminder: python src/quickstart.py
Then, start a web dyno:
heroku ps:scale web=1
See https://devcenter.heroku.com/articles/dynos#dyno-configurations

Node/React app won't deploy on Heroku

I've tried everything I can think of and exhausted google searches. I've already ruled out the most common problems (ex: not using process.env.PORT in app.listen).
Here are the heroku logs:
2018-07-18T02:43:26.705491+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=limitless-river-42936.herokuapp.com request_id=78261d20-9656-4f24-9a50-6a8e90fe216f fwd="104.32.39.36" dyno= connect= service= status=503 bytes= protocol=https
2018-07-18T02:43:28.104845+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=limitless-river-42936.herokuapp.com request_id=dab234a8-b9d7-4bbe-aa2b-36e6c4b2fcc9 fwd="104.32.39.36" dyno= connect= service= status=503 bytes= protocol=https
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
And here is the server.js file
Any help would be greatly appreciated!
It turns out the log files weren't showing all the errors for some reason -- there was a typo in one of my imports. :)

Heroku error code=H10

I keep getting error code=H10 randomly when I start my Heroku app. Sometimes the app starts, sometimes it doesn't.
My app is built with NodeJS, Express, MySQL and JawsDB.
Here's the details in my app's log:
2017-11-26T15:21:36.906937+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=<my app name>.herokuapp.com request_id=4c63d70d-f081-44a5-b4fe-f0992116ba79 fwd="108.28.184.177" dyno= connect= service= status=503 bytes= protocol=https
2017-11-26T15:21:36.954063+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=<my app name>.herokuapp.com request_id=e42d6293-512f-4ea1-ba35-403f44e4fd9a fwd="108.28.184.177" dyno= connect= service= status=503 bytes= protocol=https
I've looked online and added favicon.ico in my public folder. Nothing changes. I've had this problem before with my previous app and I ran heroku restart and it works for that one, but doesn't for this one.

Heroku app is getting crashed

I recently learned node.js and wanted to deploy my project, which I did on Heroku. However, Heroku is giving me the error messages copied below. Though I have logged the error, I am still not able to figure out the solution.
Here are the logs:
2016-04-13T14:24:17.248681+00:00 heroku[web.1]: Process exited with status 1
2016-04-13T14:24:17.256460+00:00 heroku[web.1]: State changed from starting to c
rashed
2016-04-13T14:24:30.863162+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=rather-website.herokuapp.com request_id=770f4364-
859f-453a-a09c-7f23ddaf6eca fwd="103.248.93.93" dyno= connect= service= status=5
03 bytes=
2016-04-13T14:24:31.537783+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=rather-website.herokuapp.com request_id=16af5073-
7bb2-431e-bc08-b2fb6773eab8 fwd="103.248.93.93" dyno= connect= service= status=5
03 bytes=
2016-04-13T14:27:59.122567+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=rather-website.herokuapp.com request_id=c6ba2f2f-
7379-41bf-afc9-550c309e7200 fwd="103.248.93.93" dyno= connect= service= status=5
03 bytes=
2016-04-13T14:29:17.354776+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=rather-website.herokuapp.com request_id=088965d7-
ddcf-46ba-a44c-ed1486938993 fwd="103.248.93.93" dyno= connect= service= status=5
03 bytes=
2016-04-13T14:29:21.657898+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=rather-website.herokuapp.com request_id=94d1eceb-
fa46-4795-82f6-4c369eb04fb6 fwd="103.248.93.93" dyno= connect= service= status=5
03 bytes=
2016-04-13T14:29:24.198371+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=rather-website.herokuapp.com request_id=6ff6b6be-
e29c-4a5b-b48b-cbf4f4850ccf fwd="103.248.93.93" dyno= connect= service= status=5
03 bytes=
2016-04-13T14:29:28.987226+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=rather-website.herokuapp.com request_id=1a1709f0-
9967-4ff0-a9d3-473e147c23e1 fwd="103.248.93.93" dyno= connect= service= status=5
03 bytes=
Here is the error:
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.
The node.js server is crashing upon HTTP GET request on route /. This isn't a platform error, but a code error (likely your index.js file). You will want to check the code for error between the lines:
app.get('/', function(req, res) {
//likely some syntax error here
}
I highly recommend running the app on your local machine using command such as: node index.js to see what part of your HTTP GET code is causing the error. The CLI will give a specific line number on where the error is being caused.
Heroku Local is also a great tool for testing your app before deploying it to heroku.

Resources