diff --git a/lib/events.js b/lib/events.js index ee17a22c7e7..fa680ad4557 100644 --- a/lib/events.js +++ b/lib/events.js @@ -91,8 +91,10 @@ process.EventEmitter.prototype.removeListener = function (type, listener) { var i = list.indexOf(listener); if (i < 0) return this; list.splice(i, 1); + if (list.length == 0) + delete this._events[type]; } else if (this._events[type] === listener) { - this._events[type] = null; + delete this._events[type]; } return this;