baryshev/connect-domain

Causes app crashes if response is closed

Opened this issue · 0 comments

If the request handler is asynchronous (and anything other than a timer, which is cleaned up specially in domain.dispose() - an http request for a slow resource is a good example), and the client closes its connection (calling domain.dispose to be called, which calls res.end()), then when our request handler's async method returns, it runs in the app's domain, not the request domain (which no longer exists), and any calls to res.writeHead() will now cause an app-level crash (saying headers have already been written).

Fix is probably to just not call domain.dispose() in response to 'close' on the response object.