From 6b2a9dce27edca0675356a55d450e4b0845957f7 Mon Sep 17 00:00:00 2001 From: oskarwojciski Date: Tue, 28 Nov 2023 23:08:20 +0100 Subject: [PATCH] Clear lastVersion in a case of returning an empty TokenBucketState --- tokenbucket.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tokenbucket.go b/tokenbucket.go index b79d843..b63727a 100644 --- a/tokenbucket.go +++ b/tokenbucket.go @@ -364,6 +364,12 @@ func (t *TokenBucketRedis) State(ctx context.Context) (TokenBucketState, error) var values []interface{} var err error done := make(chan struct{}, 1) + + if t.raceCheck { + // reset in a case of returning an empty TokenBucketState + t.lastVersion = 0 + } + go func() { defer close(done) keys := []string{