From 4add3fb896d550375293b28300f6433bdefb928c Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 28 Mar 2024 16:52:02 +0200 Subject: [PATCH] Cancel gaia pairing on phone too if HTTP requests is canceled --- libgm/pair_google.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libgm/pair_google.go b/libgm/pair_google.go index d5a7d1c..d457717 100644 --- a/libgm/pair_google.go +++ b/libgm/pair_google.go @@ -322,6 +322,13 @@ func (c *Client) DoGaiaPairing(ctx context.Context, emojiCallback func(string)) emojiCallback(pairingEmoji) finishResp, err := c.sendGaiaPairingMessage(ctx, ps, gmproto.ActionType_CREATE_GAIA_PAIRING_CLIENT_FINISHED, clientFinish) if err != nil { + if errors.Is(err, context.Canceled) { + zerolog.Ctx(ctx).Debug().Msg("Sending gaia pairing cancel after context was canceled") + cancelErr := c.cancelGaiaPairing(ps) + if cancelErr != nil { + zerolog.Ctx(ctx).Warn().Err(err).Msg("Failed to send gaia pairing cancel request after context was canceled") + } + } return fmt.Errorf("failed to send client finish: %w", err) } if finishResp.GetFinishErrorType() != 0 {