Skip to content

Commit

Permalink
[event] improve warning message of "possible memory leak"
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Tugarev <[email protected]>
  • Loading branch information
AlexTugarev committed Sep 13, 2019
1 parent 4360a39 commit dbb25e0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/common/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export interface Event<T> {

export namespace Event {
const _disposable = { dispose(): void { } };
export const None: Event<any> = Object.assign(function (): { dispose(): void } { return _disposable; }, {
export const None: Event<any> = Object.assign(function (): { dispose(): void } { return _disposable; }, {
get maxListeners(): number { return 0; },
set maxListeners(maxListeners: number) { }
});
Expand Down Expand Up @@ -195,8 +195,8 @@ export class Emitter<T> {

return result;
}, {
maxListeners: 30
}
maxListeners: 30
}
);
}
return this._event;
Expand All @@ -208,7 +208,7 @@ export class Emitter<T> {
}
const count = this._callbacks.length;
if (count > maxListeners) {
console.warn(new Error(`Possible Emitter memory leak detected. ${maxListeners} exit listeners added. Use event.maxListeners to increase limit`));
console.warn(new Error(`Possible Emitter memory leak detected. ${count} listeners added. Use event.maxListeners to increase the limit (${maxListeners})`));
}
}

Expand Down

0 comments on commit dbb25e0

Please sign in to comment.