From 2efd1f7f182912edaf40928a68a58b7d07a0d224 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 8 Aug 2024 11:35:41 +0200 Subject: [PATCH] redis.Client#XReadUntilResult(): also re-try timeout errors An XREAD with BLOCK sets a socket timeout of BLOCK+10s. If reading the response hits that timeout, it's not re-tried due to BLOCK. Hence, we have to re-ty it by ourselves. --- redis/client.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/redis/client.go b/redis/client.go index 5110ae4c..8934276e 100644 --- a/redis/client.go +++ b/redis/client.go @@ -216,8 +216,12 @@ func (c *Client) XReadUntilResult(ctx context.Context, a *redis.XReadArgs) ([]re cmd := c.XRead(ctx, a) streams, err := cmd.Result() if err != nil { - if errors.Is(err, redis.Nil) { - continue + if errors.Is(err, redis.Nil) || retry.Retryable(err) { + select { + case <-ctx.Done(): + default: + continue + } } return streams, WrapCmdErr(cmd)