From d586a758199cc2f664bed6b9879508d08f184fec Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Fri, 12 Apr 2024 18:51:28 -0500 Subject: [PATCH] Prevent sending shadowing healthcheck on a closed connection Co-authored-by: Sergey Skrobotov --- ts/textsecure/WebsocketResources.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ts/textsecure/WebsocketResources.ts b/ts/textsecure/WebsocketResources.ts index 087ca70265..e79518d463 100644 --- a/ts/textsecure/WebsocketResources.ts +++ b/ts/textsecure/WebsocketResources.ts @@ -447,6 +447,7 @@ export class WebSocketResourceWithShadowing implements IWebSocketResource { this.main.close(); if (this.shadowing) { this.shadowing.close(); + this.shadowing = undefined; } else { this.shadowingConnection.abort(); } @@ -456,6 +457,7 @@ export class WebSocketResourceWithShadowing implements IWebSocketResource { this.main.shutdown(); if (this.shadowing) { this.shadowing.shutdown(); + this.shadowing = undefined; } else { this.shadowingConnection.abort(); } @@ -482,11 +484,12 @@ export class WebSocketResourceWithShadowing implements IWebSocketResource { } private async sendShadowRequest(): Promise { - // it could be that we're still connecting libsignal websocket - // in which case we're skipping the check + // In the shadowing mode, it could be that we're either + // still connecting libsignal websocket or have already closed it. + // In those cases we're not running shadowing check. if (!this.shadowing) { log.info( - `${this.logId}: skipping healthcheck - websocket not connected yet` + `${this.logId}: skipping healthcheck - websocket not connected or already closed` ); return; }