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.
This commit is contained in:
Toni Spets
2025-06-25 08:55:21 +03:00
parent a49818b863
commit 8ac519d1e5
+6 -4
View File
@@ -493,10 +493,12 @@ func (t *TelegramClient) onConnectionStateChange(reason string) func() {
func (t *TelegramClient) onAuthError(err error) { func (t *TelegramClient) onAuthError(err error) {
t.sendBadCredentialsOrUnknownError(err) t.sendBadCredentialsOrUnknownError(err)
t.userLogin.Metadata.(*UserLoginMetadata).ResetOnLogout() t.userLogin.Metadata.(*UserLoginMetadata).ResetOnLogout()
t.Disconnect() go func() {
if err := t.userLogin.Save(context.Background()); err != nil { t.Disconnect()
t.main.Bridge.Log.Err(err).Msg("failed to save user login") 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) { func (t *TelegramClient) Connect(ctx context.Context) {