From 5b74c934de2f49920c1cc6b5010423c3d5de7aed Mon Sep 17 00:00:00 2001 From: Arthur Schreiber Date: Thu, 19 Sep 2024 15:37:16 +0000 Subject: [PATCH] Clean up `socketError` function. --- src/connection.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/connection.ts b/src/connection.ts index 7c2c6aacb..5447d7ca4 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -2384,12 +2384,10 @@ class Connection extends EventEmitter { * @private */ socketError(error: Error) { - if (this.state === this.STATE.CONNECTING || this.state === this.STATE.SENT_TLSSSLNEGOTIATION) { - this.emit('connect', this.wrapSocketError(error)); - } else { - this.emit('error', this.wrapSocketError(error)); - } this.dispatchEvent('socketError', error); + process.nextTick(() => { + this.emit('error', this.wrapSocketError(error)); + }); } /**