diff --git a/lib/events.js b/lib/events.js index 682a9280b13..ee6e366716e 100644 --- a/lib/events.js +++ b/lib/events.js @@ -99,8 +99,8 @@ process.EventEmitter.prototype.removeListener = function (type, listener) { process.EventEmitter.prototype.removeAllListeners = function (type) { // does not use listeners(), so no side effect of creating _events[type] - if (!type || !this._events || !this._events[type]) return this; - this._events[type] = null; + if (type && this._events && this._events[type]) this._events[type] = null; + return this; }; process.EventEmitter.prototype.listeners = function (type) {