title: Unable to call dispose on domain at appropriate time
body: <p>I'm having an issue with the <code>domain</code> module. Currently, I'm trying to catch any uncaught errors that are thrown in a request. Using an <code>express</code> middleware and domains. All requests are routed through this function before calling <code>next</code> and moving on to it's proper route. </p>
  
  <pre><code>app.use (req, res, next) -&gt;
      domain = createDomain()
      domain.on "error", (err) -&gt;
          res.send(500)
          domain.dispose()
  
      domain.enter()
      next()
  </code></pre>
  
  <p>The problem is, how do I dispose of the domain if an error is never thrown?</p>
  
  <p>I could hoist the domain and event outside the middlewear so I don't ever have to dispose, but then I won't have access to middlewear args that I need to send a 500. </p>
  
  <p>Does anyone have a better solution to how I am handling this? I've spent way too much time trying to figure out a way (and many hacky ways) to handle this. Thanks.</p>