summary refs log tree commit diff
path: root/util/src
diff options
context:
space:
mode:
Diffstat (limited to 'util/src')
-rw-r--r--util/src/util/Event.ts2
1 files changed, 2 insertions, 0 deletions
diff --git a/util/src/util/Event.ts b/util/src/util/Event.ts
index bf9547b1..8ed009d5 100644
--- a/util/src/util/Event.ts
+++ b/util/src/util/Event.ts
@@ -46,7 +46,9 @@ export async function listenEvent(event: string, callback: (event: EventOpts) =>
 	} else {
 		const cancel = () => {
 			events.removeListener(event, callback);
+			events.setMaxListeners(events.getMaxListeners() - 1);
 		};
+		events.setMaxListeners(events.getMaxListeners() + 1);
 		events.addListener(event, (opts) => callback({ ...opts, cancel }));
 
 		return cancel;