From 60e3cf9c018175d38ed06ff9e0a070d1e6112275 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 8 Apr 2026 00:41:12 +0300 Subject: [PATCH] gotd/tgerr: reduce default flood wait max duration --- pkg/connector/chatsync.go | 4 +++- pkg/gotd/tgerr/flood_wait.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/connector/chatsync.go b/pkg/connector/chatsync.go index b74fdd39..b0a68bf1 100644 --- a/pkg/connector/chatsync.go +++ b/pkg/connector/chatsync.go @@ -102,9 +102,11 @@ func (tc *TelegramClient) syncChats(ctx context.Context, takeoutID int64, onLogi dialogs, err := APICallWithUpdates(ctx, tc, func() (tg.ModifiedMessagesDialogs, error) { var dialogs tg.MessagesDialogsBox retry := true + attempts := 0 var err error - for retry { + for retry && attempts < 5 { retry, err = tgerr.FloodWait(ctx, tc.client.Invoke(ctx, wrappedReq, &dialogs)) + attempts++ } if err != nil { return nil, err diff --git a/pkg/gotd/tgerr/flood_wait.go b/pkg/gotd/tgerr/flood_wait.go index b3fab8ca..d147dc1c 100644 --- a/pkg/gotd/tgerr/flood_wait.go +++ b/pkg/gotd/tgerr/flood_wait.go @@ -66,7 +66,7 @@ func FloodWaitWithMaxDuration(d time.Duration) FloodWaitOption { func FloodWait(ctx context.Context, err error, opts ...FloodWaitOption) (bool, error) { opt := &floodWaitOptions{ clock: clock.System, - maxDuration: 1 * time.Hour, + maxDuration: 5 * time.Minute, } for _, o := range opts { o.apply(opt)