From 55be00d689cd178e56fb85eeab4c39672476f318 Mon Sep 17 00:00:00 2001 From: trevor-signal <131492920+trevor-signal@users.noreply.github.com> Date: Wed, 28 Feb 2024 12:48:01 -0500 Subject: [PATCH] Add timeout to avatar fetches and avoid blocking on profile syncs --- ts/background.ts | 12 ++++++++---- ts/textsecure/WebAPI.ts | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ts/background.ts b/ts/background.ts index 1eb358dbe..6b4d3f320 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -3041,13 +3041,15 @@ export async function startApp(): Promise { drop(ViewOnceOpenSyncs.onSync(attributes)); } - async function onFetchLatestSync(ev: FetchLatestEvent): Promise { - ev.confirm(); + function onFetchLatestSync(ev: FetchLatestEvent): void { + // Don't block on fetchLatestSync events + drop(doFetchLatestSync(ev)); + } + async function doFetchLatestSync(ev: FetchLatestEvent): Promise { const { eventType } = ev; const FETCH_LATEST_ENUM = Proto.SyncMessage.FetchLatest.Type; - switch (eventType) { case FETCH_LATEST_ENUM.LOCAL_PROFILE: { log.info('onFetchLatestSync: fetching latest local profile'); @@ -3058,7 +3060,7 @@ export async function startApp(): Promise { } case FETCH_LATEST_ENUM.STORAGE_MANIFEST: log.info('onFetchLatestSync: fetching latest manifest'); - await StorageService.runStorageServiceSyncJob(); + StorageService.runStorageServiceSyncJob(); break; case FETCH_LATEST_ENUM.SUBSCRIPTION_STATUS: log.info('onFetchLatestSync: fetching latest subscription status'); @@ -3068,6 +3070,8 @@ export async function startApp(): Promise { default: log.info(`onFetchLatestSync: Unknown type encountered ${eventType}`); } + + ev.confirm(); } async function onKeysSync(ev: KeysEvent) { diff --git a/ts/textsecure/WebAPI.ts b/ts/textsecure/WebAPI.ts index 27a2e4318..73a069c4f 100644 --- a/ts/textsecure/WebAPI.ts +++ b/ts/textsecure/WebAPI.ts @@ -1984,7 +1984,7 @@ export function initialize({ contentType: 'application/octet-stream', proxyUrl, responseType: 'bytes', - timeout: 0, + timeout: 90 * SECOND, type: 'GET', redactUrl: (href: string) => { const pattern = RegExp(escapeRegExp(path), 'g');