1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-25 12:45:18 +01:00

Catch redis connection exception (#3582)

* Handle RedisConnectionException

* Log warning on exception
This commit is contained in:
Justin Baur 2023-12-15 09:58:32 -05:00 committed by GitHub
parent 343cf03d3e
commit 699b884441
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,9 +66,10 @@ public class CustomRedisProcessingStrategy : RedisProcessingStrategy
{
return await base.ProcessRequestAsync(requestIdentity, rule, counterKeyBuilder, rateLimitOptions, cancellationToken);
}
catch (RedisTimeoutException)
catch (Exception ex) when (ex is RedisTimeoutException || ex is RedisConnectionException)
{
// If this is the first timeout we've had, start a new counter and sliding window
_logger.LogWarning(ex, "Redis appears down, skipping rate limiting");
// If this is the first timeout/connection error we've had, start a new counter and sliding window
timeoutCounter ??= new TimeoutCounter()
{
Count = 0,