"unknown interaction" due to high traffic
When my bot encounters heavy burst loads it will encounter "interaction failed" on the user end, and "unknown interaction" on the bot end. In my button handler logic I defer reply on the first line, so it should respond within the 3s. This would happen for around 15-30 minutes, and the bot would start to actually respond. In some cases it would show the defer reply state and stay there for around 5-10 minutes, and then finally change to the actual response, or in some cases it wouldn't update at all, probably due to the interaction expiring.
For some data the first event we used the bot for had around 600 button interactions per minute, which had zero problems, and then the next few events sat at around 2k interactions per minute, that's when the problems started. These are also averaged out at 30minutes, which means the initial interactions would be way more
14 Replies
discord js version of 14.21 and node 22/24

tag suggestion for @ganr:
Common causes of
DiscordAPIError[10062]: Unknown interaction:
- Initial response took more than 3 seconds ➞ defer the response *.
- Wrong interaction object inside a collector.
- Two processes handling the same command (the first consumes the interaction, so it won't be valid for the other instance)
* Note: you cannot defer modal or autocomplete value responsesdid you read what i wrote
It is possible that there is enough load on the bot that it's not able to defer all interactions within 3 seconds either, that has happened to me before, but I am not 100% sure
that could happen, but I don't think that's the case
is doing db read and writes going to slow down the bot so that it can't defer the interactions?
i don't think any interactions go through within the first 10 minutes of the high load coming in
also from my memory usage on my server, I can see that it can handle it

the first 10 minutes all interactions would come back as interaction failed
anyways I have updated the bot so that the button interaction handler only does a defer reply, and then puts puts the rest of the logic into a queue
if it were really my other logic slowing the interaction handler down then this should mitigate that
the queue is a seperate process
i thought interactions don't have ratelimits
which are not applied to the interactions endpoints?

In this setup, the button handlers only task is to defer the reply and store all relevant information into redis. A separate server then retrieves this data and performs the other operations, so that any potential slowdowns don’t affect the bot's ability to respond to interactions within 3s. I’ve also implemented retry logic, so any failed attempts are automatically retried after a few seconds.
Alternatively you can use something like upstash workflows, or amazon sqs, instead of running your own
hopefully this implementation will be tested, as I still don't know if the game community is going to use the bot or not
if it does gets used, then i'll update on it's results
and i'll also ask for more money :)
unfortunately you can't have a button with modals though, and all your button replies are ephemeral
if those two things aren't an issue then go ahead
yes for my use case it's fine
this is how my deployment is setup
