You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the notification service sends a large number of messages within a short time window, Discord will return a failure response indicating that the message was not accepted due to rate limiting, and will provide a timer in which requests will become accepted again (usually 1-2 seconds). The naive implementation of the current system does not handle failures and simply drops the message completely. This means that we could have the case where notifications are generated but never seen in Discord due to being dropped by the rate limiting response.
To fix this, we need to look at the response generated from the curl call and see if there's a failure due to rate limiting. If so, place the message on a queue and retry later once the limiting period has expired. When a new message is about to be sent, the queue should first be checked and if any messages are in the queue, add the new message to the queue instead of sending. The queue should only hold valid messages. If any other failures occur due to invalid formatting or other issues that will not automatically resolve, the message should be dropped (and possibly logged).
All of this logic should take place in notification_service.php. This is a low priority item as we don't expect rate limiting to be a problem under most circumstances. Although forums that are very active will have a higher likelihood of encountering this problem.
The text was updated successfully, but these errors were encountered:
I stumbled upon this tonight from a bot in the Discord API channel describing all the rate limits. The one we care about is REST/POST, which allows for 5 messages sent in a 5 second period. So if forums are generating more activity than 5 events in 5 seconds, they would experience some messages dropped.
If the notification service sends a large number of messages within a short time window, Discord will return a failure response indicating that the message was not accepted due to rate limiting, and will provide a timer in which requests will become accepted again (usually 1-2 seconds). The naive implementation of the current system does not handle failures and simply drops the message completely. This means that we could have the case where notifications are generated but never seen in Discord due to being dropped by the rate limiting response.
To fix this, we need to look at the response generated from the curl call and see if there's a failure due to rate limiting. If so, place the message on a queue and retry later once the limiting period has expired. When a new message is about to be sent, the queue should first be checked and if any messages are in the queue, add the new message to the queue instead of sending. The queue should only hold valid messages. If any other failures occur due to invalid formatting or other issues that will not automatically resolve, the message should be dropped (and possibly logged).
All of this logic should take place in notification_service.php. This is a low priority item as we don't expect rate limiting to be a problem under most circumstances. Although forums that are very active will have a higher likelihood of encountering this problem.
The text was updated successfully, but these errors were encountered: