0

Different users trying to access different application routes with heavy manipulation of data. At the mid time one of the request failed due to internal server error and my whole application has been crashed. Thats why other request has been failed because build has been crashed. Is there any solution to handle this situation?

narayansharma91
  • 2,273
  • 1
  • 12
  • 20
  • Tell me about your application little bit more, Are you using Express based framework? – Dilip Kola Jun 12 '18 at 11:47
  • Yes iam using express based framework. Let example 10 users is uploading some file on our server at same time. Inbetween some exception occurred and application has been crashed. Due to this reason other 10 users request can't be success. How should we stop this problem? So that 1 problem does not affect other users. – narayansharma91 Jun 12 '18 at 11:56
  • 1
    Have you configured Error handlers in the APP: https://expressjs.com/en/guide/error-handling.html at minimum use this error handler: `app.use(function (err, req, res, next) { console.error(err.stack) res.status(500).send('Something broke!') })` – Dilip Kola Jun 12 '18 at 12:02

1 Answers1

1

If your program has thrown an uncaught error and crashed then there's nothing you can really do other than start it back up again. You could use something like pm2 to automatically restart your node process when it crashes, and then at least future requests that come in should work (although you will lose any in memory data from before the last crash).

Another thing that I think would help you would be to move your backend onto a serverless architecture where each invocation of your code is independent of the others.

And of course try to fix the code so that it handles things gracefully and doesn't actually throw errors. :)

Jim
  • 3,821
  • 1
  • 28
  • 60