diff --git a/src/vs/base/common/event.ts b/src/vs/base/common/event.ts index 4ab515e5253be..f94fa3673b6e3 100644 --- a/src/vs/base/common/event.ts +++ b/src/vs/base/common/event.ts @@ -1065,7 +1065,7 @@ export class Emitter { */ get event(): Event { this._event ??= (callback: (e: T) => any, thisArgs?: any, disposables?: IDisposable[] | DisposableStore) => { - if (this._leakageMon && this._size > this._leakageMon.threshold * 3) { + if (this._leakageMon && this._size > this._leakageMon.threshold ** 2) { const message = `[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`; console.warn(message); diff --git a/src/vs/base/test/common/event.test.ts b/src/vs/base/test/common/event.test.ts index 7c33d1f41afdc..161c7085fa6ae 100644 --- a/src/vs/base/test/common/event.test.ts +++ b/src/vs/base/test/common/event.test.ts @@ -376,14 +376,14 @@ suite('Event', function () { const a = ds.add(new Emitter({ onListenerError(e) { allError.push(e); }, - leakWarningThreshold: 1, + leakWarningThreshold: 3, })); - for (let i = 0; i < 5; i++) { + for (let i = 0; i < 11; i++) { a.event(() => { }, undefined, store); } - assert.deepStrictEqual(allError.length, 4); + assert.deepStrictEqual(allError.length, 5); const [start, tail] = tail2(allError); assert.ok(tail instanceof ListenerRefusalError);