Skip to content

Commit

Permalink
Suggested fix for winstonjs#213: More than 10 containers triggers Eve…
Browse files Browse the repository at this point in the history
…ntEmitter memory leak warning
  • Loading branch information
mwittig committed Jun 3, 2015
1 parent 445da9c commit 5999c70
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/winston/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
};

Expand Down

0 comments on commit 5999c70

Please sign in to comment.