Handle libsignal websocket connect() errors
This commit is contained in:
parent
5e767d45a2
commit
7d25988888
3 changed files with 22 additions and 11 deletions
|
@ -1311,7 +1311,8 @@ export async function startApp(): Promise<void> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.warn('background: remote expiration detected, disabling reconnects');
|
log.error('background: remote expiration detected, disabling reconnects');
|
||||||
|
drop(window.storage.put('remoteBuildExpiration', Date.now()));
|
||||||
drop(server?.onRemoteExpiration());
|
drop(server?.onRemoteExpiration());
|
||||||
remotelyExpired = true;
|
remotelyExpired = true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
// Copyright 2021 Signal Messenger, LLC
|
// Copyright 2021 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import type { Net } from '@signalapp/libsignal-client';
|
import {
|
||||||
|
ErrorCode,
|
||||||
|
LibSignalErrorBase,
|
||||||
|
type Net,
|
||||||
|
} from '@signalapp/libsignal-client';
|
||||||
import URL from 'url';
|
import URL from 'url';
|
||||||
import type { RequestInit, Response } from 'node-fetch';
|
import type { RequestInit, Response } from 'node-fetch';
|
||||||
import { Headers } from 'node-fetch';
|
import { Headers } from 'node-fetch';
|
||||||
|
@ -278,7 +282,7 @@ export class SocketManager extends EventListener {
|
||||||
const { code } = error;
|
const { code } = error;
|
||||||
|
|
||||||
if (code === 401 || code === 403) {
|
if (code === 401 || code === 403) {
|
||||||
this.emit('authError', error);
|
this.emit('authError');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,6 +296,18 @@ export class SocketManager extends EventListener {
|
||||||
}
|
}
|
||||||
} else if (error instanceof ConnectTimeoutError) {
|
} else if (error instanceof ConnectTimeoutError) {
|
||||||
this.markOffline();
|
this.markOffline();
|
||||||
|
} else if (
|
||||||
|
error instanceof LibSignalErrorBase &&
|
||||||
|
error.code === ErrorCode.DeviceDelinked
|
||||||
|
) {
|
||||||
|
this.emit('authError');
|
||||||
|
return;
|
||||||
|
} else if (
|
||||||
|
error instanceof LibSignalErrorBase &&
|
||||||
|
error.code === ErrorCode.AppExpired
|
||||||
|
) {
|
||||||
|
window.Whisper.events.trigger('httpResponse499');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
drop(reconnect());
|
drop(reconnect());
|
||||||
|
@ -931,10 +947,7 @@ export class SocketManager extends EventListener {
|
||||||
|
|
||||||
// EventEmitter types
|
// EventEmitter types
|
||||||
|
|
||||||
public override on(
|
public override on(type: 'authError', callback: () => void): this;
|
||||||
type: 'authError',
|
|
||||||
callback: (error: HTTPError) => void
|
|
||||||
): this;
|
|
||||||
public override on(type: 'statusChange', callback: () => void): this;
|
public override on(type: 'statusChange', callback: () => void): this;
|
||||||
public override on(type: 'online', callback: () => void): this;
|
public override on(type: 'online', callback: () => void): this;
|
||||||
public override on(type: 'offline', callback: () => void): this;
|
public override on(type: 'offline', callback: () => void): this;
|
||||||
|
@ -951,7 +964,7 @@ export class SocketManager extends EventListener {
|
||||||
return super.on(type, listener);
|
return super.on(type, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override emit(type: 'authError', error: HTTPError): boolean;
|
public override emit(type: 'authError'): boolean;
|
||||||
public override emit(type: 'statusChange'): boolean;
|
public override emit(type: 'statusChange'): boolean;
|
||||||
public override emit(type: 'online'): boolean;
|
public override emit(type: 'online'): boolean;
|
||||||
public override emit(type: 'offline'): boolean;
|
public override emit(type: 'offline'): boolean;
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
// Copyright 2020 Signal Messenger, LLC
|
// Copyright 2020 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import * as log from '../logging/log';
|
|
||||||
import type { HTTPError } from './Errors';
|
import type { HTTPError } from './Errors';
|
||||||
|
|
||||||
export async function handleStatusCode(status: number): Promise<void> {
|
export async function handleStatusCode(status: number): Promise<void> {
|
||||||
if (status === 499) {
|
if (status === 499) {
|
||||||
log.error('Got 499 from Signal Server. Build is expired.');
|
|
||||||
await window.storage.put('remoteBuildExpiration', Date.now());
|
|
||||||
window.Whisper.events.trigger('httpResponse499');
|
window.Whisper.events.trigger('httpResponse499');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue