From 445da9c721dae64e2932a0cb088fa95ae80d7577 Mon Sep 17 00:00:00 2001 From: marcus Date: Wed, 3 Jun 2015 12:15:44 +0200 Subject: [PATCH 1/2] Suggested fix for #213: More than 10 containers triggers EventEmitter memory leak warning --- lib/winston/logger.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/winston/logger.js b/lib/winston/logger.js index 936a13b8f..5c750849c 100755 --- a/lib/winston/logger.js +++ b/lib/winston/logger.js @@ -460,8 +460,10 @@ Logger.prototype.add = function (transport, options, created) { // // Listen for the `error` event on the new Transport // - instance._onError = this._onError.bind(this, instance) - instance.on('error', instance._onError); + if (! created) { + instance._onError = this._onError.bind(this, instance) + instance.on('error', instance._onError); + } // // If this transport has `handleExceptions` set to `true` From 5999c70b8295a9e3e4b5296aac4f6f7bf0c00217 Mon Sep 17 00:00:00 2001 From: marcus Date: Wed, 3 Jun 2015 12:26:45 +0200 Subject: [PATCH 2/2] Suggested fix for #213: More than 10 containers triggers EventEmitter memory leak warning --- lib/winston/logger.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/winston/logger.js b/lib/winston/logger.js index 5c750849c..27d3af8bb 100755 --- a/lib/winston/logger.js +++ b/lib/winston/logger.js @@ -460,8 +460,8 @@ Logger.prototype.add = function (transport, options, created) { // // Listen for the `error` event on the new Transport // + instance._onError = this._onError.bind(this, instance) if (! created) { - instance._onError = this._onError.bind(this, instance) instance.on('error', instance._onError); } @@ -531,7 +531,9 @@ Logger.prototype.remove = function (transport) { instance.close(); } - instance.removeListener('error', instance._onError); + if (instance._onError) { + instance.removeListener('error', instance._onError); + } return this; };