fix(SimpleIdentifyThrottler): don't sleep negative amounts (#10669)

* fix(SimpleIdentifyThrottler): don't sleep negative amounts

* fix: test
This commit is contained in:
Denis-Adrian Cristea
2024-12-31 20:16:57 +02:00
committed by Jiralite
parent 737a97d068
commit be38128ea1
2 changed files with 37 additions and 12 deletions

View File

@@ -36,7 +36,7 @@ export class SimpleIdentifyThrottler implements IIdentifyThrottler {
try {
const diff = state.resetsAt - Date.now();
if (diff <= 5_000) {
if (diff > 0 && diff <= 5_000) {
// To account for the latency the IDENTIFY payload goes through, we add a bit more wait time
const time = diff + Math.random() * 1_500;
await sleep(time);