discord.js icon indicating copy to clipboard operation
discord.js copied to clipboard

Request handler doesn't fire the ratelimit event on sublimits

Open HxX2 opened this issue 3 years ago • 4 comments

Which package is this bug report for?

discord.js

Issue description

When I try to change the channel name more than twice, The third request status returns 429 but the rate limit won't emit, And the request handler should queue the third and prevent hitting the sublimity. for more info check this thread on discord.js server

image

Code sample

const client = new Client();
client.on('debug', info => console.log(info));
client.on('rateLimit', (rateLimitData) => console.log(rateLimitData));
await client.login(token);

Package version

13.8.1

Node.js version

17.9.1

Operating system

Linux (debian)

Priority this issue should have

High (immediate attention needed)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

Guilds, GuildMembers, GuildMessages

I have tested this issue on a development release

No response

HxX2 avatar Jul 03 '22 13:07 HxX2

expected behavior: image

HxX2 avatar Jul 03 '22 13:07 HxX2

The rateLimit event is fired when discord.js preemptively blocks a request from hitting a rate limit, not when we encounter an actual ratelimit. By the time a request is re-queued the ratelimit may have already expired.

Sublimits are a bit of an interesting case. Because we can't properly track the requests ratelimit data we need to stall sublimited requests manually. In this case it may seem pertinent to emit the event manually too. However, I'd rather suggest a new event sublimitted or similar.

ckohen avatar Jul 09 '22 20:07 ckohen

The rateLimit event is fired when discord.js preemptively blocks a request from hitting a rate limit, not when we encounter an actual ratelimit. By the time a request is re-queued the ratelimit may have already expired.

Sublimits are a bit of an interesting case. Because we can't properly track the requests ratelimit data we need to stall sublimited requests manually. In this case it may seem pertinent to emit the event manually too. However, I'd rather suggest a new event sublimitted or similar.

yeah I know that rateLimit event is emited when d.js blocks a request from hitting a rate limit but we need the same behavior in sublimits to prevent the client from hitting the rate limit.

HxX2 avatar Jul 11 '22 16:07 HxX2

That's not how sublimits work, we don't know about them until we hit them, and even then we don't know what combination of parameters cauesd it. We get no information about it other than when to retry

ckohen avatar Jul 11 '22 21:07 ckohen