4 ms·
Killing a process on an exception you can't handle is sort of best practice anyway in Node--assuming you're not building important financial services or whateve
by james-mcelwain 10y ago
Killing a process on an exception you can't handle is sort of best practice anyway in Node--assuming you're not building important financial services or whatever in Node (lol).
Like, you want to be careful not to open yourself up to cascading failure, but if my application has a random exception, the 100ms start up time of the JavaScript VM means its almost always worth the cost of restarting to ensure your application isn't in an unstable state.
- Touche 10y agoWhat makes you think I can't handle it? I definitely can handle it, and Promises give me the ability to handle them.
- deleted 10y ago[deleted]
- danneu 10y agoI'd rethink that. Every connection to the server closes, and whatever else it might be doing stops, because someone hits your syntax error? And they completely DoS your server by slowly refreshing the page? Surely the best practice is to use something like koa or otherwise create a promise chain with a top-level 500 handler.
- mnutt 10y agoDepending on how much state your applications carry forward, I think killing the process is often the right thing to do. Otherwise, it's very easy to end up with connection leaks or just downright confusing state that can't always easily be traced back to what should have been an exception. I run a node app that serves ~500M requests a day that is configured to die on exceptions, it just means that we do everything we can to prevent them (unit tests, linters, etc) and take them very seriously when they happen.