Add timeout to avatar fetches and avoid blocking on profile syncs

This commit is contained in:
trevor-signal 2024-02-28 12:48:01 -05:00 committed by GitHub
parent c64aa86736
commit 55be00d689
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View file

@ -3041,13 +3041,15 @@ export async function startApp(): Promise<void> {
drop(ViewOnceOpenSyncs.onSync(attributes));
}
async function onFetchLatestSync(ev: FetchLatestEvent): Promise<void> {
ev.confirm();
function onFetchLatestSync(ev: FetchLatestEvent): void {
// Don't block on fetchLatestSync events
drop(doFetchLatestSync(ev));
}
async function doFetchLatestSync(ev: FetchLatestEvent): Promise<void> {
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<void> {
}
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<void> {
default:
log.info(`onFetchLatestSync: Unknown type encountered ${eventType}`);
}
ev.confirm();
}
async function onKeysSync(ev: KeysEvent) {