diff --git a/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/MultiAPIBucket.cs b/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/MultiAPIBucket.cs index e9c434293..5d9a31d87 100644 --- a/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/MultiAPIBucket.cs +++ b/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/MultiAPIBucket.cs @@ -63,6 +63,10 @@ public void SetRESTBucketState(int maximumAvailable, double currentlyAvailable) public void SetGraphQLBucketState(int maximumAvailable, int restoreRatePerSecond, double currentlyAvailable, int refund) { + //There seems to be a bug in the GraphQL API. It sometimes returns a currentlyAvailable larger than maximumAvailable. + if (currentlyAvailable > maximumAvailable) + currentlyAvailable = maximumAvailable; + currentlyAvailable = Math.Max(0, Math.Min(currentlyAvailable, GraphQLBucket.ComputedCurrentlyAvailable + refund)); GraphQLBucket.SetState(maximumAvailable, restoreRatePerSecond, currentlyAvailable); }