"App Crashed" in Heroku log

Asked

Viewed 59 times

0

I am having a problem with my Node application that is on the Heroku server. When I make many requests for the same route /oapi/login the application stops running, the error that the log returns is this:

2020-01-18T14:41:27.184911+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=OPTIONS path="/oapi/login" host=expenses-server-api.herokuapp.com request_id=171e102c-befe-45d2-9415-6899a84adf54 fwd="201.182.211.10" dyno= connect= service= status=503 bytes= protocol=https

And then I can no longer access other application routes.

Remarks:

  • I’m using Mongoose for the bank connection
  • The archive package json. is configured correctly
  • The archive Procfile is correct too
  • All environment variables are set
  • Put the route code, I believe it’s overloading the server, so it crashes

1 answer

0


In the code I was just sending reply without making any Exception treats, so when any connection to the bank was made, I put the block try / catch.

Old Code:

await Model.find((err, resp) => {
   if (err) {
      return res.status(400).json(err);
   } else {
      return res.status(200).json(resp);
   }
});

Current Code:

try {
   await Model.find((err, resp) => {
      if (err) {
         return res.status(400).json(err);
      } else {
         return res.status(200).json(resp);
      }
   });
} catch (err) {
   return res.status(400).json(err);
}

Of course that was my case, yours may be different, but now I can make as many wrong requests as the server does not go to (Crashed App).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.