diff --git a/lib/application.js b/lib/application.js index 7a4c318..e59b8a3 100644 --- a/lib/application.js +++ b/lib/application.js @@ -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); }