add socket error-handling. Closes #6

otherwise node just explodes, not a good default
This commit is contained in:
TJ Holowaychuk 2013-08-21 19:52:01 -07:00
parent b4b0789d7a
commit fe89dc3783

View file

@ -119,11 +119,14 @@ app.context = function(obj){
app.callback = function(){
var mw = [respond].concat(this.middleware);
var fn = compose(mw)(downstream);
var onerror = this.onerror.bind(this);
var self = this;
return function(req, res){
var ctx = new self.Context(self, req, res);
ctx.socket.on('error', onerror);
function done(err) {
if (err) ctx.onerror(err);
}