diff --git a/core/middlewares/recovery/recovery.go b/core/middlewares/recovery/recovery.go index 821e92076b..6d69de354a 100644 --- a/core/middlewares/recovery/recovery.go +++ b/core/middlewares/recovery/recovery.go @@ -33,7 +33,7 @@ func (r *recovery) Handle(next tg.Invoker) telegram.InvokeFunc { return backoff.RetryNotify(func() error { if err := next.Invoke(ctx, input, output); err != nil { - if r.shouldRecover(err) { + if r.shouldRecover(ctx, err) { return errors.Wrap(err, "recover") } @@ -47,11 +47,13 @@ func (r *recovery) Handle(next tg.Invoker) telegram.InvokeFunc { } } -func (r *recovery) shouldRecover(err error) bool { +func (r *recovery) shouldRecover(ctx context.Context, err error) bool { // context in recovery is used to stop recovery process by external os signal, otherwise we will wait till max retries when user press ctrl+c select { case <-r.ctx.Done(): return false + case <-ctx.Done(): + return false default: }