Skip to content

Commit

Permalink
Properly handle connection timeout on unauthenticated websocket
Browse files Browse the repository at this point in the history
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
  • Loading branch information
automated-signal and indutny-signal committed Jul 29, 2021
1 parent aca88f5 commit 49c7a70
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ts/textsecure/SocketManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 49c7a70

Please sign in to comment.