From fa28593635558efe3c3a40fa2ef0f8c8edc3702e Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 5 Dec 2025 15:37:43 +0200 Subject: [PATCH] handlematrix: don't block read receipt handler on reaction poll --- pkg/connector/handlematrix.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/connector/handlematrix.go b/pkg/connector/handlematrix.go index 8ab67e52..b9cbfb2d 100644 --- a/pkg/connector/handlematrix.go +++ b/pkg/connector/handlematrix.go @@ -651,7 +651,7 @@ func (t *TelegramClient) HandleMatrixReadReceipt(ctx context.Context, msg *bridg return parseErr } - var readMentionsErr, readReactionsErr, readMessagesErr, reactionPollErr error + var readMentionsErr, readReactionsErr, readMessagesErr error var wg sync.WaitGroup // Read mentions @@ -717,11 +717,12 @@ func (t *TelegramClient) HandleMatrixReadReceipt(ctx context.Context, msg *bridg } }() - // Poll for reactions - wg.Add(1) + // Poll for reactions (non-blocking to avoid deadlock when portal event buffer is disabled) go func() { - defer wg.Done() - reactionPollErr = t.maybePollForReactions(ctx, msg.Portal) + err := t.maybePollForReactions(ctx, msg.Portal) + if err != nil { + log.Err(err).Msg("failed to poll for reactions after read receipt") + } }() if peerType == ids.PeerTypeChannel && !msg.Portal.Metadata.(*PortalMetadata).FullSynced { @@ -736,7 +737,7 @@ func (t *TelegramClient) HandleMatrixReadReceipt(ctx context.Context, msg *bridg } wg.Wait() - return errors.Join(readMentionsErr, readReactionsErr, readMessagesErr, reactionPollErr) + return errors.Join(readMentionsErr, readReactionsErr, readMessagesErr) } func (t *TelegramClient) HandleMatrixTyping(ctx context.Context, msg *bridgev2.MatrixTyping) error {