From d1bfaba549fe380d269c26cea0a0183ed1520a85 Mon Sep 17 00:00:00 2001 From: Dom Parfitt Date: Tue, 1 Nov 2022 21:09:37 +0000 Subject: [PATCH] fix: capture error correctly in withConn --- redis.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/redis.go b/redis.go index 4d683f75..04940915 100644 --- a/redis.go +++ b/redis.go @@ -288,11 +288,9 @@ func (c *baseClient) withConn( return err } - defer func() { - c.releaseConn(ctx, cn, err) - }() - - return fn(ctx, cn) + err = fn(ctx, cn) + c.releaseConn(ctx, cn, err) + return err } func (c *baseClient) dial(ctx context.Context, network, addr string) (net.Conn, error) {