summary refs log tree commit diff
path: root/gateway/src/events/Close.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-12 21:53:57 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-12 21:53:57 +0200
commitf2e8e2e0311bc343a21c3de94f6a1e908be81c2c (patch)
treea9c157945c7b8d5429a33513e3979114a2c37c3a /gateway/src/events/Close.ts
parent:zap: benchmark tests (diff)
downloadserver-f2e8e2e0311bc343a21c3de94f6a1e908be81c2c.tar.xz
:zap: improve memory managment
Diffstat (limited to 'gateway/src/events/Close.ts')
-rw-r--r--gateway/src/events/Close.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/gateway/src/events/Close.ts b/gateway/src/events/Close.ts
index 1299ad5c..5c1bd292 100644
--- a/gateway/src/events/Close.ts
+++ b/gateway/src/events/Close.ts
@@ -1,10 +1,13 @@
 import { WebSocket } from "@fosscord/gateway";
-import { Message } from "./Message";
 import { Session } from "@fosscord/util";
 
 export async function Close(this: WebSocket, code: number, reason: string) {
 	console.log("[WebSocket] closed", code, reason);
 	if (this.session_id) await Session.delete({ session_id: this.session_id });
-	// @ts-ignore
-	this.off("message", Message);
+	if (this.heartbeatTimeout) clearTimeout(this.heartbeatTimeout);
+	if (this.readyTimeout) clearTimeout(this.readyTimeout);
+
+	this.deflate?.close();
+
+	this.removeAllListeners();
 }