From 8695474d045d3d5e9887a50219e5de44b840c532 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Fri, 29 Aug 2025 21:28:14 +1200 Subject: [PATCH] remove event listeners on timeout --- src/connection/connection.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/connection/connection.js b/src/connection/connection.js index d6e2986..5e46f65 100644 --- a/src/connection/connection.js +++ b/src/connection/connection.js @@ -1433,6 +1433,9 @@ class Connection extends EventEmitter { // reject login request as timed out after estimated delay, plus a bit extra const estTimeout = response.estTimeout + extraTimeoutMillis; timeoutHandler = setTimeout(() => { + this.off(Constants.ResponseCodes.Err, onErr); + this.off(Constants.ResponseCodes.Sent, onSent); + this.off(Constants.PushCodes.LoginSuccess, onLoginSuccess); reject("timeout"); }, estTimeout); @@ -1496,6 +1499,9 @@ class Connection extends EventEmitter { // reject login request as timed out after estimated delay, plus a bit extra const estTimeout = response.estTimeout + extraTimeoutMillis; timeoutHandler = setTimeout(() => { + this.off(Constants.ResponseCodes.Err, onErr); + this.off(Constants.ResponseCodes.Sent, onSent); + this.off(Constants.PushCodes.StatusResponse, onStatusResponsePush); reject("timeout"); }, estTimeout); @@ -1581,6 +1587,9 @@ class Connection extends EventEmitter { // reject as timed out after estimated delay, plus a bit extra const estTimeout = response.estTimeout + extraTimeoutMillis; timeoutHandler = setTimeout(() => { + this.off(Constants.ResponseCodes.Err, onErr); + this.off(Constants.ResponseCodes.Sent, onSent); + this.off(Constants.PushCodes.TelemetryResponse, onTelemetryResponsePush); reject("timeout"); }, estTimeout);