Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
events: emit removeListener event when last listener is removed
When the last listener is removed and _eventsCount becomes 0,
the removeListener event was not being emitted because the check
was inside the else block. This moves the removeListener emission
outside the conditional to ensure it always fires when a listener
is removed.
  • Loading branch information
Han5991 committed Jan 24, 2026
commit 598fbb4d5d8ea25f78f91631ca550e9e7ba68c7e
5 changes: 3 additions & 2 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,9 +687,10 @@ EventEmitter.prototype.removeListener =
this._events = { __proto__: null };
} else {
delete events[type];
if (events.removeListener)
this.emit('removeListener', type, list.listener || listener);
}

if (events.removeListener !== undefined)
this.emit('removeListener', type, list.listener || listener);
} else if (typeof list !== 'function') {
let position = -1;

Expand Down
Loading