From 8ac519d1e5b00160c124e34a4b57b45e6bcd2634 Mon Sep 17 00:00:00 2001 From: Toni Spets Date: Wed, 25 Jun 2025 08:55:21 +0300 Subject: [PATCH] connector: Disconnect in a goroutine on auth error If we get bad creds on initial connect the lock is being held when the callback is called. --- pkg/connector/client.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/connector/client.go b/pkg/connector/client.go index ef717161..e7b926d3 100644 --- a/pkg/connector/client.go +++ b/pkg/connector/client.go @@ -493,10 +493,12 @@ func (t *TelegramClient) onConnectionStateChange(reason string) func() { func (t *TelegramClient) onAuthError(err error) { t.sendBadCredentialsOrUnknownError(err) t.userLogin.Metadata.(*UserLoginMetadata).ResetOnLogout() - t.Disconnect() - if err := t.userLogin.Save(context.Background()); err != nil { - t.main.Bridge.Log.Err(err).Msg("failed to save user login") - } + go func() { + t.Disconnect() + if err := t.userLogin.Save(context.Background()); err != nil { + t.main.Bridge.Log.Err(err).Msg("failed to save user login") + } + }() } func (t *TelegramClient) Connect(ctx context.Context) {