getProfiles: Better logging; don't let promise propagate

This commit is contained in:
Scott Nonnenberg 2024-03-25 10:03:15 -07:00 committed by GitHub
parent 83e0e5d33b
commit a39e46db5c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 49 additions and 12 deletions

View file

@ -4645,7 +4645,11 @@ export class ConversationModel extends window.Backbone
onChangeProfileKey(): void {
if (isDirectConversation(this.attributes)) {
void this.getProfiles();
drop(
this.getProfiles().catch(() => {
/* nothing to do here; logging already happened */
})
);
}
}

View file

@ -1048,7 +1048,11 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
switch (error.name) {
case 'OutgoingIdentityKeyError': {
if (conversation) {
promises.push(conversation.getProfiles());
promises.push(
conversation.getProfiles().catch(() => {
/* nothing to do here; logging already happened */
})
);
}
break;
}

View file

@ -142,10 +142,17 @@ export async function routineProfileRefresh({
);
successCount += 1;
} catch (err) {
log.error(
`${logId}: refreshed profile for ${conversation.idForLogging()}`,
Errors.toLogFormat(err)
);
if ('code' in err) {
log.warn(
`${logId}: refreshed profile for ${conversation.idForLogging()},`,
`got error code ${err.code}`
);
} else {
log.error(
`${logId}: refreshed profile for ${conversation.idForLogging()}`,
Errors.toLogFormat(err)
);
}
}
}

View file

@ -1601,7 +1601,13 @@ async function processRemoteRecords(
);
// Intentionally not awaiting
needProfileFetch.map(convo => drop(convo.getProfiles()));
needProfileFetch.map(convo =>
drop(
convo.getProfiles().catch(() => {
/* nothing to do here; logging already happened */
})
)
);
// Collect full map of previously and currently unknown records
const unknownRecords: Map<string, UnknownRecord> = new Map();

View file

@ -1064,7 +1064,11 @@ export async function mergeContactRecord(
) {
// Local name doesn't match remote name, fetch profile
if (localName) {
void conversation.getProfiles();
drop(
conversation.getProfiles().catch(() => {
/* nothing to do here; logging already happened */
})
);
details.push('refreshing profile');
} else {
conversation.set({

View file

@ -11,6 +11,8 @@ export async function toggleVerification(id: string): Promise<void> {
export async function reloadProfiles(id: string): Promise<void> {
const contact = window.getConversations().get(id);
if (contact) {
await contact.getProfiles();
await contact.getProfiles().catch(() => {
/* nothing to do here; logging already happened */
});
}
}

View file

@ -2741,7 +2741,11 @@ function getProfilesForConversation(conversationId: string): NoopActionType {
throw new Error('getProfilesForConversation: no conversation found');
}
void conversation.getProfiles();
drop(
conversation.getProfiles().catch(() => {
/* nothing to do here; logging already happened */
})
);
return {
type: 'NOOP',
@ -2765,7 +2769,11 @@ function conversationStoppedByMissingVerification(payload: {
}
// Intentionally not awaiting here
void conversation.getProfiles();
drop(
conversation.getProfiles().catch(() => {
/* nothing to do here; logging already happened */
})
);
});
return {
@ -4274,7 +4282,9 @@ function onConversationOpened(
conversation.throttledGetProfiles !== undefined,
'Conversation model should be initialized'
);
await conversation.throttledGetProfiles();
await conversation.throttledGetProfiles().catch(() => {
/* nothing to do here; logging already happened */
});
}
drop(conversation.updateVerified());