From 244876abc442f57822cccbe942e37c7a980cf74f Mon Sep 17 00:00:00 2001 From: Aleksandr Razumov Date: Wed, 9 Oct 2024 13:21:02 +0300 Subject: [PATCH] Revert "fix(telegram): reset backoff on connection ready" This reverts commit 23e26dc7c7c3d14166af27c6f5d2bc26747f9475. --- telegram/connect.go | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/telegram/connect.go b/telegram/connect.go index a4d484f567..f93ebbaf22 100644 --- a/telegram/connect.go +++ b/telegram/connect.go @@ -61,36 +61,23 @@ func (c *Client) reconnectUntilClosed(ctx context.Context) error { // Note that we currently have no timeout on connection, so this is // potentially eternal. b := tdsync.SyncBackoff(backoff.WithContext(c.connBackoff(), ctx)) - g := tdsync.NewCancellableGroup(ctx) - g.Go(func(ctx context.Context) error { - select { - case <-ctx.Done(): - return ctx.Err() - case <-c.ready.Ready(): - // Reset backoff on successful connection. - b.Reset() - return nil - } - }) - g.Go(func(ctx context.Context) error { - return backoff.RetryNotify(func() error { - if err := c.runUntilRestart(ctx); err != nil { - if c.isPermanentError(err) { - return backoff.Permanent(err) - } - return err + + return backoff.RetryNotify(func() error { + if err := c.runUntilRestart(ctx); err != nil { + if c.isPermanentError(err) { + return backoff.Permanent(err) } + return err + } - return nil - }, b, func(err error, timeout time.Duration) { - c.log.Info("Restarting connection", zap.Error(err), zap.Duration("backoff", timeout)) + return nil + }, b, func(err error, timeout time.Duration) { + c.log.Info("Restarting connection", zap.Error(err), zap.Duration("backoff", timeout)) - c.connMux.Lock() - c.conn = c.createPrimaryConn(nil) - c.connMux.Unlock() - }) + c.connMux.Lock() + c.conn = c.createPrimaryConn(nil) + c.connMux.Unlock() }) - return g.Wait() } func (c *Client) onReady() {