Skip to content

Commit

Permalink
fix: don’t add default listener when listeners >0
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Aug 28, 2024
1 parent 2294a61 commit d68512f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions commons/lib/TypedEventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ export default class TypedEventEmitter<T> extends EventEmitter implements ITyped
eventType: K,
listenerFn: (this: this, event?: T[K]) => any,
): this {
// if we're adding an error logger, we can remove the default logger
if (eventType === 'error' && listenerFn !== this.defaultErrorLogger as any) {
// if we're removing an error logger, we should add back the default logger
if (eventType === 'error' && listenerFn !== this.defaultErrorLogger as any && super.listenerCount(eventType) === 1) {
super.on('error', this.defaultErrorLogger);
}
return super.off(eventType, listenerFn);
Expand Down

0 comments on commit d68512f

Please sign in to comment.