From 4e4fcfc6427f5cac499d3b8927bc61579eb18150 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Thu, 22 Aug 2013 11:52:22 -0700 Subject: [PATCH] fix socket error handler event listener leak --- lib/application.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/application.js b/lib/application.js index e59b8a3..8af42bc 100644 --- a/lib/application.js +++ b/lib/application.js @@ -125,7 +125,9 @@ app.callback = function(){ return function(req, res){ var ctx = new self.Context(self, req, res); - ctx.socket.on('error', onerror); + if (!~ctx.socket.listeners('error').indexOf(onerror)) { + ctx.socket.on('error', onerror); + } function done(err) { if (err) ctx.onerror(err);