remove event listeners on timeout

This commit is contained in:
liamcottle 2025-08-29 21:28:14 +12:00
parent 95107eb2eb
commit 8695474d04

View file

@ -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);