Skip to content

Commit

Permalink
client: try reconnecting on update manager run error
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <[email protected]>
  • Loading branch information
sumnerevans committed Dec 5, 2024
1 parent 4d33af7 commit 73934a0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/connector/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,10 @@ func connectTelegramClient(ctx context.Context, client *telegram.Client) (contex
select {
case <-ctx.Done(): // context canceled
cancel()
return nil, func() {}, ctx.Err()
return nil, func() {}, fmt.Errorf("context cancelled before init done: %w", ctx.Err())
case err := <-errC: // startup timeout
cancel()
return nil, func() {}, err
return nil, func() {}, fmt.Errorf("client connection timeout: %w", err)
case <-initDone: // init done
}

Expand Down Expand Up @@ -431,7 +431,7 @@ func (t *TelegramClient) onConnectionStateChange(reason string) func() {
if errors.Is(err, syscall.EPIPE) {
// This is a pipe error, try reconnecting
t.Disconnect()
t.Connect(ctx)
t.Connect(t.main.Bridge.Log.WithContext(context.Background()))
} else {
t.sendBadCredentialsOrUnknownError(err)
}
Expand Down Expand Up @@ -470,7 +470,8 @@ func (t *TelegramClient) Connect(ctx context.Context) {
if err != nil {
zerolog.Ctx(ctx).Err(err).Msg("failed to run updates manager")
t.sendBadCredentialsOrUnknownError(err)
t.clientCancel()
t.Disconnect()
t.Connect(t.main.Bridge.Log.WithContext(context.Background()))
}
}()

Expand Down

0 comments on commit 73934a0

Please sign in to comment.