Browse Source

Don't disable when there's no resetTick

Sometimes Discord won't send any ratelimit headers, disabling the semaphore for endpoints that should have them.
pull/1546/head
Paulo 5 years ago
parent
commit
4d8c3f5c65
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs

+ 5
- 3
src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs View File

@@ -277,16 +277,16 @@ namespace Discord.Net.Queue
#endif
}

if (resetTick == null)
/*if (resetTick == null)
{
WindowCount = 0; //No rate limit info, disable limits on this bucket (should only ever happen with a user token)
#if DEBUG_LIMITS
Debug.WriteLine($"[{id}] Disabled Semaphore");
#endif
return;
}
}*/

if (!hasQueuedReset || resetTick > _resetTick)
if (resetTick != null && (!hasQueuedReset || resetTick > _resetTick))
{
_resetTick = resetTick;
LastAttemptAt = resetTick.Value; //Make sure we dont destroy this until after its been reset
@@ -299,6 +299,8 @@ namespace Discord.Net.Queue
var _ = QueueReset(id, (int)Math.Ceiling((_resetTick.Value - DateTimeOffset.UtcNow).TotalMilliseconds));
}
}
else if (!hasQueuedReset && _semaphore == 0)
_semaphore = WindowCount; //Prevent getting locked at 0/1 if Discord doesn't send the ratelimit headers
}
}
private async Task QueueReset(int id, int millis)


Loading…
Cancel
Save