Skip to content

On Discord we hit an API throttling #167

@damienalexandre

Description

@damienalexandre

Not the same as #153

An error occurs in production:

Client error: GET https://discordapp.com/api/v6/guilds/***/members?limit=200&after=*** resulted in a 429 Too Many Requests response.

I thing that when we fetch the members of the guild we should be less agressive in the for loop.

do {
if ((time() - $startTime) > 19) {
throw new UserExtractionFailedException(DiscordApplication::APPLICATION_CODE, 'Took too much time to retrieve all the users on your team.');
}
$lastMember = $lastMembers ? end($lastMembers) : null;
try {
/** @var GuildMember[] $members */
$lastMembers = $this->apiHelper->getMembersInGuild($guildId, $lastMember ? $lastMember->user->id : null);
} catch (\Throwable $t) {
throw new UserExtractionFailedException(DiscordApplication::APPLICATION_CODE, 'Could not fetch members in guild.', $t);
}
$members = array_merge($members, $lastMembers);
} while (!empty($lastMembers));

Adding a "sleep" maybe?

There is also a lot of headers to help us mitigate this issue: https://discord.com/developers/docs/topics/rate-limits

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy