@@ -406,20 +406,22 @@ impl<T: GlobalLimiter> RedisRateLimiter<T> {
406406 }
407407 }
408408
409- // We check the global rate limits before the other limits. This step must be separate from
410- // checking the other rate limits, since those are checked with a Redis script that works
411- // under the invariant that all keys are within the same Redis instance (given their partitioning).
412- // Global keys on the other hand are always on the same instance, so if they were to be mixed
413- // with normal keys the script will end up referencing keys from multiple instances, making it
414- // impossible for the script to work.
415- let rate_limited_global_quotas = self
416- . global_limiter
417- . check_global_rate_limits ( & global_quotas)
418- . await ?;
419-
420- for quota in rate_limited_global_quotas {
421- let retry_after = self . retry_after ( ( quota. expiry ( ) - timestamp) . as_secs ( ) ) ;
422- rate_limits. add ( RateLimit :: from_quota ( quota, * item_scoping, retry_after) ) ;
409+ if !global_quotas. is_empty ( ) {
410+ // We check the global rate limits before the other limits. This step must be separate from
411+ // checking the other rate limits, since those are checked with a Redis script that works
412+ // under the invariant that all keys are within the same Redis instance (given their partitioning).
413+ // Global keys on the other hand are always on the same instance, so if they were to be mixed
414+ // with normal keys the script will end up referencing keys from multiple instances, making it
415+ // impossible for the script to work.
416+ let rate_limited_global_quotas = self
417+ . global_limiter
418+ . check_global_rate_limits ( & global_quotas)
419+ . await ?;
420+
421+ for quota in rate_limited_global_quotas {
422+ let retry_after = self . retry_after ( ( quota. expiry ( ) - timestamp) . as_secs ( ) ) ;
423+ rate_limits. add ( RateLimit :: from_quota ( quota, * item_scoping, retry_after) ) ;
424+ }
423425 }
424426
425427 // Either there are no quotas to run against Redis, or we already have a rate limit from a
0 commit comments