Skip to content

Commit

Permalink
Fix NRE when ratelimmited requests don't return a body (#2135)
Browse files Browse the repository at this point in the history
  • Loading branch information
CottageDwellingCat committed Mar 2, 2022
1 parent 553055b commit b95b942
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs
Expand Up @@ -377,7 +377,8 @@ private void UpdateRateLimit(int id, IRequest request, RateLimitInfo info, bool
// use the payload reset after value
var payload = info.ReadRatelimitPayload(body);

resetTick = DateTimeOffset.UtcNow.Add(TimeSpan.FromSeconds(payload.RetryAfter));
// fallback on stored ratelimit info when payload is null, https://github.com/discord-net/Discord.Net/issues/2123
resetTick = DateTimeOffset.UtcNow.Add(TimeSpan.FromSeconds(payload?.RetryAfter ?? info.ResetAfter?.TotalSeconds ?? 0));
#if DEBUG_LIMITS
Debug.WriteLine($"[{id}] Reset-After: {info.ResetAfter.Value} ({info.ResetAfter?.TotalMilliseconds} ms)");
#endif
Expand Down

0 comments on commit b95b942

Please sign in to comment.