From fe89dc37838c0cc7d0e083fbe6536e66cc4efd81 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Wed, 21 Aug 2013 19:52:01 -0700 Subject: [PATCH] add socket error-handling. Closes #6 otherwise node just explodes, not a good default --- lib/application.js | 3 +++ 1 file changed, 3 insertions(+) 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); }