From 67887cec22ea8609c00efc9c49d2b90332098f10 Mon Sep 17 00:00:00 2001 From: ayn2op Date: Mon, 15 Dec 2025 05:40:19 -0500 Subject: [PATCH] refactor(qr): move ticker to local scope --- internal/login/qr.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/internal/login/qr.go b/internal/login/qr.go index c6cd681..f4b0104 100644 --- a/internal/login/qr.go +++ b/internal/login/qr.go @@ -200,13 +200,6 @@ func (q *qrLogin) run(ctx context.Context) { } }() - var heartbeatTicker *time.Ticker - defer func() { - if heartbeatTicker != nil { - heartbeatTicker.Stop() - } - }() - for { select { case <-ctx.Done(): @@ -237,8 +230,9 @@ func (q *qrLogin) run(ctx context.Context) { return } if h.HeartbeatInterval > 0 { - heartbeatTicker = time.NewTicker(time.Duration(h.HeartbeatInterval) * time.Millisecond) + heartbeatTicker := time.NewTicker(time.Duration(h.HeartbeatInterval) * time.Millisecond) go func() { + defer heartbeatTicker.Stop() for { select { case <-ctx.Done():