mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Don't poll websocket on remote expiration
This commit is contained in:
@@ -1332,6 +1332,10 @@ export async function startApp(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (remotelyExpired) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.info('reconnectToWebSocket starting...');
|
||||
await server.reconnect();
|
||||
});
|
||||
@@ -1352,6 +1356,16 @@ export async function startApp(): Promise<void> {
|
||||
void unlinkAndDisconnect();
|
||||
});
|
||||
|
||||
window.Whisper.events.on('httpResponse499', () => {
|
||||
if (remotelyExpired) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.warn('background: remote expiration detected, disabling reconnects');
|
||||
remotelyExpired = true;
|
||||
onOffline();
|
||||
});
|
||||
|
||||
async function runStorageService() {
|
||||
StorageService.enableStorageService();
|
||||
}
|
||||
@@ -1554,6 +1568,10 @@ export async function startApp(): Promise<void> {
|
||||
}
|
||||
|
||||
function onOnline() {
|
||||
if (remotelyExpired) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.info('online');
|
||||
|
||||
window.removeEventListener('online', onOnline);
|
||||
@@ -1604,12 +1622,18 @@ export async function startApp(): Promise<void> {
|
||||
|
||||
let connectCount = 0;
|
||||
let connecting = false;
|
||||
let remotelyExpired = false;
|
||||
async function connect(firstRun?: boolean) {
|
||||
if (connecting) {
|
||||
log.warn('connect already running', { connectCount });
|
||||
return;
|
||||
}
|
||||
|
||||
if (remotelyExpired) {
|
||||
log.warn('remotely expired, not reconnecting');
|
||||
return;
|
||||
}
|
||||
|
||||
strictAssert(server !== undefined, 'WebAPI not connected');
|
||||
|
||||
try {
|
||||
@@ -1711,7 +1735,9 @@ export async function startApp(): Promise<void> {
|
||||
server.registerRequestHandler(messageReceiver);
|
||||
|
||||
// If coming here after `offline` event - connect again.
|
||||
await server.onOnline();
|
||||
if (!remotelyExpired) {
|
||||
await server.onOnline();
|
||||
}
|
||||
|
||||
void AttachmentDownloads.start({
|
||||
logger: log,
|
||||
|
||||
@@ -8,6 +8,7 @@ export async function handleStatusCode(status: number): Promise<void> {
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user