diff --git a/ts/groups.ts b/ts/groups.ts index 24dc55b585d5..a4112ce403b6 100644 --- a/ts/groups.ts +++ b/ts/groups.ts @@ -23,7 +23,7 @@ import dataInterface from './sql/Client'; import { toWebSafeBase64, fromWebSafeBase64 } from './util/webSafeBase64'; import { assertDev, strictAssert } from './util/assert'; import { isMoreRecentThan } from './util/timestamp'; -import { MINUTE, DurationInSeconds } from './util/durations'; +import { MINUTE, DurationInSeconds, SECOND } from './util/durations'; import { dropNull } from './util/dropNull'; import type { ConversationAttributesType, @@ -93,6 +93,7 @@ import { import { ReadStatus } from './messages/MessageReadStatus'; import { SeenStatus } from './MessageSeenStatus'; import { incrementMessageCounter } from './util/incrementMessageCounter'; +import { sleep } from './util/sleep'; type AccessRequiredEnum = Proto.AccessControl.AccessRequired; @@ -3135,7 +3136,12 @@ async function updateGroup( if (changeMessagesToSave.length > 0) { try { - await profileFetches; + if (contactsWithoutProfileKey && contactsWithoutProfileKey.length > 0) { + await Promise.race([profileFetches, sleep(30 * SECOND)]); + log.info( + `updateGroup/${logId}: timed out or finished fetching ${contactsWithoutProfileKey.length} profiles` + ); + } } catch (error) { log.error( `updateGroup/${logId}: failed to fetch missing profiles`, diff --git a/ts/services/profiles.ts b/ts/services/profiles.ts index 3291896eb166..28f6107cfe8a 100644 --- a/ts/services/profiles.ts +++ b/ts/services/profiles.ts @@ -141,6 +141,12 @@ export class ProfileService { `ProfileServices.get: Job for ${conversation.idForLogging()} finished ${delta}ms after queue` ); } + const remainingItems = this.jobQueue.size; + if (remainingItems && remainingItems % 10 === 0) { + log.info( + `ProfileServices.get: ${remainingItems} jobs remaining in the queue` + ); + } } };