title: Prevent Express.js from crashing
body: <p>I'm quite new to Express.js and one of the things that surprised me more at first, compare to other servers such as Apache or IIS, is that <strong>Express.js server crashes</strong> every time it encounters an uncatched exception or some error <strong>turning down the site</strong> and making it accessible for users. A terrible thing!</p>
  
  <p>For example, my application is crashing with a Javascript error because a variable is not defined due to a name change in the database table. </p>
  
  <blockquote>
    <p>TypeError: Cannot call method 'replace' of undefined</p>
  </blockquote>
  
  <p><em>This is not such a good example, because I should solve it before moving the site to production, but sometimes similar errors can take part which shouldn't be causing a server crash.</em></p>
  
  <p>I would expect to see an error page or just an error in that specific page, but <strong>turning down the whole server</strong> for these kind of things sounds terrifying.</p>
  
  <p><a href="http://expressjs.com/guide/error-handling.html" rel="nofollow">Express error handlers</a> doesn't seem to be enough for this purposes.</p>
  
  <p>I've been reading about how to solve this kind of things in Node.js <a href="http://shapeshed.com/uncaught-exceptions-in-node/" rel="nofollow">by using domains</a>, but I found nothing specifically for Express.js.</p>
  
  <p>Another option I found, which doesn't seem to be recommended in all cases, is using tools to keep running a process forever, so after a crash, it would restart itself. Tools like <a href="https://github.com/nodejitsu/forever" rel="nofollow">Forever</a>, <a href="http://upstart.ubuntu.com/" rel="nofollow">Upstart</a> or <a href="http://mmonit.com/monit/" rel="nofollow">Monit</a>.</p>
  
  <p>How do you guys deal with this kind of problems in Express.js?</p>