diff --git a/internal/retry/retry.go b/internal/retry/retry.go index 385cab8..861644a 100644 --- a/internal/retry/retry.go +++ b/internal/retry/retry.go @@ -18,6 +18,7 @@ var internalErrors = []string{ "RPC_MCGET_FAIL", "WORKER_BUSY_TOO_LONG_RETRY", "memory limit exit", + "connection dead", } type retry struct { @@ -25,13 +26,22 @@ type retry struct { errors []string } +func isErrorMatch(err error) bool { + for _, internalError := range internalErrors { + if errors.Is(err, errors.New(internalError)) { + return true + } + } + return false +} + func (r retry) Handle(next tg.Invoker) telegram.InvokeFunc { return func(ctx context.Context, input bin.Encoder, output bin.Decoder) error { retries := 0 for retries < r.max { if err := next.Invoke(ctx, input, output); err != nil { - if tgerr.Is(err, r.errors...) { + if tgerr.Is(err, r.errors...) || isErrorMatch(err) { retries++ continue }