diff --git a/commons/lib/TypedEventEmitter.ts b/commons/lib/TypedEventEmitter.ts index 8d6ae4a..4a8a4d9 100644 --- a/commons/lib/TypedEventEmitter.ts +++ b/commons/lib/TypedEventEmitter.ts @@ -125,8 +125,8 @@ export default class TypedEventEmitter 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);