Discord.js: Messages stuck in queue

Created on 11 May 2018  Â·  1Comment  Â·  Source: discordjs/discord.js

Please describe the problem you are having in as much detail as possible:
When replying to commands, messages will sometimes get "stuck" and will not be properly sent until the bot attempts to send another message in that channel, causing it to spit out any queued up messages. Probably important to mention that Pokécord (The bot having this problem) requires a lot of activity, meaning it is more likely to be rate limited.

The issue seems to be the same as #1949 and #1985 , however both of these issues were on older versions of discord.js.

Further details:

  • discord.js version: Master
  • API request method: Sequential
  • node.js version: 8.10.0
  • Operating system: CentOS 7
  • Priority this issue should have – Medium - Depends on the size and functionality of the bot.

  • [ ] I found this issue while running code on a __user account__

  • [x] I have also tested the issue on latest master, commit hash:
medium ratelimits bug

Most helpful comment

After looking into the issue I have found the problem:

In sequential.js the handler will return if:

  • A request is already being handled (this.busy)
  • The queue is empty (this.queue.length === 0)
  • The bot is being rate limited (this.limited)

After some testing I found that the requests would get stuck if they were handled while this.limited was true, and after looking into it more the problem came from the bot being globally rate limited.

When a bot is globally rate limited discord.js will correctly stop sending requests by setting this.globallyLimited to true, however if a request is queued while the bot is globally rate limited it will stop handling the requests all together.

All that is needed to fix this issue is a way of getting discord.js to start handling requests again after the global rate limit clears.

>All comments

After looking into the issue I have found the problem:

In sequential.js the handler will return if:

  • A request is already being handled (this.busy)
  • The queue is empty (this.queue.length === 0)
  • The bot is being rate limited (this.limited)

After some testing I found that the requests would get stuck if they were handled while this.limited was true, and after looking into it more the problem came from the bot being globally rate limited.

When a bot is globally rate limited discord.js will correctly stop sending requests by setting this.globallyLimited to true, however if a request is queued while the bot is globally rate limited it will stop handling the requests all together.

All that is needed to fix this issue is a way of getting discord.js to start handling requests again after the global rate limit clears.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DatMayo picture DatMayo  Â·  3Comments

kvn1351 picture kvn1351  Â·  3Comments

shukriadams picture shukriadams  Â·  3Comments

xCuzImPro picture xCuzImPro  Â·  3Comments

Alipoodle picture Alipoodle  Â·  3Comments