From d4a30a0165d0ca0135df6ab47bf15d58e5f5458e Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Thu, 29 Jul 2021 09:25:21 -0700 Subject: [PATCH] Properly handle connection timeout on unauthenticated websocket --- ts/textsecure/SocketManager.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ts/textsecure/SocketManager.ts b/ts/textsecure/SocketManager.ts index 79b644f04..e765f8c25 100644 --- a/ts/textsecure/SocketManager.ts +++ b/ts/textsecure/SocketManager.ts @@ -407,7 +407,17 @@ export class SocketManager extends EventListener { }); this.unauthenticated = process; - const unauthenticated = await this.unauthenticated.getResult(); + let unauthenticated: WebSocketResource; + try { + unauthenticated = await this.unauthenticated.getResult(); + } catch (error) { + window.log.info( + 'SocketManager: failed to connect unauthenticated socket ' + + ` due to error: ${Errors.toLogFormat(error)}` + ); + this.dropUnauthenticated(process); + throw error; + } window.log.info('SocketManager: connected unauthenticated socket'); @@ -540,8 +550,10 @@ export class SocketManager extends EventListener { { abort() { if (resource) { + window.log.warn(`SocketManager closing socket ${path}`); resource.close(3000, 'aborted'); } else { + window.log.warn(`SocketManager aborting connection ${path}`); clearTimeout(timer); client.abort(); }