From 2890d5139ca33a22ef6118fc7e34391ab618f36f Mon Sep 17 00:00:00 2001 From: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com> Date: Sat, 29 Nov 2025 01:47:15 +0200 Subject: [PATCH] Update redis.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- redis.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/redis.go b/redis.go index f63933b0..a6a71067 100644 --- a/redis.go +++ b/redis.go @@ -415,11 +415,12 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error { } else { // DialTimeout is shorter, cap the wait at DialTimeout waitCtx, cancel = context.WithTimeout(ctx, dialTimeout) - defer cancel() } } else { // No command deadline, use DialTimeout to prevent waiting indefinitely waitCtx, cancel = context.WithTimeout(ctx, dialTimeout) + } + if cancel != nil { defer cancel() }