Fixes RetryMode.RetryRatelimit being ignored (#1036)
This commit is contained in:
committed by
Christopher F
parent
b8b59d97ae
commit
c618cb3ccd
@@ -163,7 +163,7 @@ namespace Discord.Net.Queue
|
|||||||
if (!isRateLimited)
|
if (!isRateLimited)
|
||||||
throw new TimeoutException();
|
throw new TimeoutException();
|
||||||
else
|
else
|
||||||
throw new RateLimitedException(request);
|
ThrowRetryLimit(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
@@ -181,13 +181,12 @@ namespace Discord.Net.Queue
|
|||||||
await _queue.RaiseRateLimitTriggered(Id, null).ConfigureAwait(false);
|
await _queue.RaiseRateLimitTriggered(Id, null).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((request.Options.RetryMode & RetryMode.RetryRatelimit) == 0)
|
ThrowRetryLimit(request);
|
||||||
throw new RateLimitedException(request);
|
|
||||||
|
|
||||||
if (resetAt.HasValue)
|
if (resetAt.HasValue)
|
||||||
{
|
{
|
||||||
if (resetAt > timeoutAt)
|
if (resetAt > timeoutAt)
|
||||||
throw new RateLimitedException(request);
|
ThrowRetryLimit(request);
|
||||||
int millis = (int)Math.Ceiling((resetAt.Value - DateTimeOffset.UtcNow).TotalMilliseconds);
|
int millis = (int)Math.Ceiling((resetAt.Value - DateTimeOffset.UtcNow).TotalMilliseconds);
|
||||||
#if DEBUG_LIMITS
|
#if DEBUG_LIMITS
|
||||||
Debug.WriteLine($"[{id}] Sleeping {millis} ms (Pre-emptive)");
|
Debug.WriteLine($"[{id}] Sleeping {millis} ms (Pre-emptive)");
|
||||||
@@ -198,7 +197,7 @@ namespace Discord.Net.Queue
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((timeoutAt.Value - DateTimeOffset.UtcNow).TotalMilliseconds < 500.0)
|
if ((timeoutAt.Value - DateTimeOffset.UtcNow).TotalMilliseconds < 500.0)
|
||||||
throw new RateLimitedException(request);
|
ThrowRetryLimit(request);
|
||||||
#if DEBUG_LIMITS
|
#if DEBUG_LIMITS
|
||||||
Debug.WriteLine($"[{id}] Sleeping 500* ms (Pre-emptive)");
|
Debug.WriteLine($"[{id}] Sleeping 500* ms (Pre-emptive)");
|
||||||
#endif
|
#endif
|
||||||
@@ -309,5 +308,11 @@ namespace Discord.Net.Queue
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ThrowRetryLimit(RestRequest request)
|
||||||
|
{
|
||||||
|
if ((request.Options.RetryMode & RetryMode.RetryRatelimit) == 0)
|
||||||
|
throw new RateLimitedException(request);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user