From 517e46c87655cd11a30c1a2bb98f0e96003c46b5 Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:12:04 -0500 Subject: [PATCH] Fix group update deadlock inside conversation queue Co-authored-by: Jamie Kyle <113370520+jamiebuilds-signal@users.noreply.github.com> --- ts/util/groupSendEndorsements.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ts/util/groupSendEndorsements.ts b/ts/util/groupSendEndorsements.ts index 3157a989011a..a1f9e6e62f8c 100644 --- a/ts/util/groupSendEndorsements.ts +++ b/ts/util/groupSendEndorsements.ts @@ -30,7 +30,7 @@ import { isTestOrMockEnvironment } from '../environment'; import { isAlpha } from './version'; import { parseStrict } from './schemas'; import { DataReader } from '../sql/Client'; -import { waitThenMaybeUpdateGroup } from '../groups'; +import { maybeUpdateGroup } from '../groups'; import { isGroupV2 } from './whatTypeOfConversation'; export function decodeGroupSendEndorsementResponse({ @@ -355,7 +355,8 @@ export async function maybeCreateGroupSendEndorsementState( if (conversation.isMember(ourAci)) { if (!alreadyRefreshedGroupState) { log.info(`${logId}: Missing endorsements for group, refreshing group`); - await waitThenMaybeUpdateGroup({ conversation, force: true }); + await window.waitForEmptyEventQueue(); + await maybeUpdateGroup({ conversation, force: true }); return { state: null, didRefreshGroupState: true }; } @@ -382,7 +383,8 @@ export async function maybeCreateGroupSendEndorsementState( log.info( `${logId}: Endorsements close to expiration (${groupSendEndorsementState.getExpiration().getTime()}, ${Date.now()}), refreshing group` ); - await waitThenMaybeUpdateGroup({ conversation, force: true }); + await window.waitForEmptyEventQueue(); + await maybeUpdateGroup({ conversation, force: true }); return { state: null, didRefreshGroupState: true }; }