diff --git a/app.go b/app.go index fbae6a01b..10a43dbce 100644 --- a/app.go +++ b/app.go @@ -99,10 +99,9 @@ func (a *App) Run() error { } wg.Wait() if a.opts.registrar != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(a.opts.ctx, a.opts.registrarTimeout) - defer cancel() - if err := a.opts.registrar.Register(ctx, instance); err != nil { + rctx, rcancel := context.WithTimeout(a.opts.ctx, a.opts.registrarTimeout) + defer rcancel() + if err := a.opts.registrar.Register(rctx, instance); err != nil { return err } a.instance = instance