From a28297c39dc8b324d60898c9639977496941502a Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 10 Nov 2021 13:04:59 +0000 Subject: [PATCH] Tweak performJoinUsingServer error handling --- federationsender/internal/perform.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/federationsender/internal/perform.go b/federationsender/internal/perform.go index 2c9e186e..623e7cb8 100644 --- a/federationsender/internal/perform.go +++ b/federationsender/internal/perform.go @@ -239,7 +239,9 @@ func (r *FederationSenderInternalAPI) performJoinUsingServer( // to complete, but if the client does give up waiting, we'll // still continue to process the join anyway so that we don't // waste the effort. + waiterr := make(chan error, 1) go func() { + defer close(waiterr) defer cancel() // TODO: Can we expand Check here to return a list of missing auth @@ -250,6 +252,7 @@ func (r *FederationSenderInternalAPI) performJoinUsingServer( "room_id": roomID, "user_id": userID, }).WithError(err).Error("Failed to process room join response") + waiterr <- err return } @@ -267,12 +270,17 @@ func (r *FederationSenderInternalAPI) performJoinUsingServer( "room_id": roomID, "user_id": userID, }).WithError(err).Error("Failed to send room join response to roomserver") + waiterr <- err return } }() - <-ctx.Done() - return nil + select { + case <-ctx.Done(): + return nil + case err := <-waiterr: + return err + } } // PerformOutboundPeekRequest implements api.FederationSenderInternalAPI