From 0b6473b88fa82e735feb67e1b1800d369fbeb8c7 Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Thu, 9 Jan 2025 20:19:26 +0100 Subject: [PATCH] f --- packages/connection/index.js | 4 ++-- packages/websocket/lib/Socket.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/connection/index.js b/packages/connection/index.js index 4889bd62..262d9cc3 100644 --- a/packages/connection/index.js +++ b/packages/connection/index.js @@ -73,7 +73,7 @@ class Connection extends EventEmitter { } _detachSocket() { - this.#socketListeners?.unsubscribe(this.socket); + this.socket && this.#socketListeners?.unsubscribe(this.socket); this.socket = null; } @@ -139,7 +139,7 @@ class Connection extends EventEmitter { } _detachParser() { - this.#parserListeners?.unsubscribe(this.parser); + this.parser && this.#parserListeners?.unsubscribe(this.parser); this.parser = null; this.root = null; } diff --git a/packages/websocket/lib/Socket.js b/packages/websocket/lib/Socket.js index 5cf8e4a5..1d551bb6 100644 --- a/packages/websocket/lib/Socket.js +++ b/packages/websocket/lib/Socket.js @@ -50,12 +50,12 @@ export default class Socket extends EventEmitter { this.emit("close", !event.wasClean, event); }, }); - this.#listeners.subscribe(socket); + this.#listeners.subscribe(this.socket); } _detachSocket() { this.url = null; - this.#listeners?.unsubscribe(this.socket); + this.socket && this.#listeners?.unsubscribe(this.socket); this.socket = null; }