1
0
mirror of https://github.com/redis/go-redis.git synced 2025-12-02 06:22:31 +03:00

Update redis.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Nedyalko Dyakov
2025-11-29 01:47:15 +02:00
committed by GitHub
parent 038cf1febc
commit 2890d5139c

View File

@@ -415,11 +415,12 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
} else { } else {
// DialTimeout is shorter, cap the wait at DialTimeout // DialTimeout is shorter, cap the wait at DialTimeout
waitCtx, cancel = context.WithTimeout(ctx, dialTimeout) waitCtx, cancel = context.WithTimeout(ctx, dialTimeout)
defer cancel()
} }
} else { } else {
// No command deadline, use DialTimeout to prevent waiting indefinitely // No command deadline, use DialTimeout to prevent waiting indefinitely
waitCtx, cancel = context.WithTimeout(ctx, dialTimeout) waitCtx, cancel = context.WithTimeout(ctx, dialTimeout)
}
if cancel != nil {
defer cancel() defer cancel()
} }