From d4d454e554cbe283ef6ad3cd4a733f49fac827e8 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Mon, 21 Jun 2021 12:06:06 -0700 Subject: [PATCH] Reject WebSocket connect timeout with an HTTPError --- ts/textsecure/WebAPI.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ts/textsecure/WebAPI.ts b/ts/textsecure/WebAPI.ts index 28f08cafac..94c3890791 100644 --- a/ts/textsecure/WebAPI.ts +++ b/ts/textsecure/WebAPI.ts @@ -305,7 +305,15 @@ async function _connectSocket( return new Promise((resolve, reject) => { const timer = setTimeout(() => { - reject(new Error('Connection timed out')); + reject( + makeHTTPError( + '_connectSocket: Connection timed out', + -1, + {}, + 'Connection timed out', + stack + ) + ); client.abort(); }, timeout); @@ -322,7 +330,7 @@ async function _connectSocket( await _handleStatusCode(statusCode); const error = makeHTTPError( - 'promiseAjax: invalid websocket response', + '_connectSocket: invalid websocket response', statusCode || -1, {}, // headers undefined, @@ -342,8 +350,8 @@ async function _connectSocket( reject( makeHTTPError( - '_connectSocket connectFailed', - 0, + '_connectSocket: connectFailed', + -1, {}, e.toString(), stack