Add timeout to avatar fetches and avoid blocking on profile syncs

Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
automated-signal
2024-02-28 18:58:44 -06:00
committed by GitHub
parent 436584742a
commit eadf9049b5
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) {

View File

@@ -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');