-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Random misleading Unknown Interaction errors #5558
Comments
Can you provide a code snippet showing how these logs were generated? |
Keep in mind this issue can happen with other kinds of interaction replies, not only deferred messages (I tested with showing a modal). I only showed that snippet because it's the most basic one that should never generate that error |
Hey @DV8FromTheWorld do you have any updates on this? |
I have been getting this too, we check if it has been 3 seconds and it definitely has not at the time of request, but sometimes get this response. |
Yeah, I have been getting this error as well. And I haven't changed my code since updating Discord.js to v14.6.0. |
I have not looked deeper into this issue at this time. This is the first time I've heard of this issue. For debugging purposes: Is there a way in your library (or tech stack) to track outbound network traffic? If there is, it would be useful to indicating whether the library is re-attempting a network call or if the initial network call is actually taking 5 seconds. From your code snippet that isn't possible to determine. |
I’m not sure if there is but I can dig into the source code and add that myself. I do, however, doubt that is the case, as we’ve seen @ooliver1 say they are experiencing the same behavior and they’re using a python library, which is completely different from the one I’m using |
It's pretty hard to reproduce confidently, since it's been random a lot of the time |
I have found that letting it sit running for multiple hours after starting the bot allows it to not have that error until you turn the bot off and try to run it again without letting it sit. |
@DV8FromTheWorld I believe there is not much more debugging I can do here. Due to this issue happening at a random chance and requiring a high volume of interactions it would be impossible to gather enough data to be able to tell exactly why it's happening. All I can tell is that, on discord.js, after calling deferReply() the request is sent to this method which I am not familiar with and I would probably need to spend a lot of time figuring out all the quirks with this class and the whole package itself. |
If it helps, I also get totally random, out of nowhere, “unknown interaction” errors in my bot logs [i run a bot using the discord.py library, so totally unrelated to the op who uses discord.js] when sending a response to an interaction. In my case, its just an immediate ephemeral response message [eg interaction.response.send_message(mymsghere, ephemeral=True) ], rather than a deference response with a use of the followup webhook. I’ve never bothered trying to work out why it happens since the error traceback shows its more likely to be a Discord issue, rather than to do with anyones’ library implementations [unless every single lib dev has implemented interactions wrongly for 2 years lol]. Also, it’ll happen once, then never again for several days, usually when i’m sleeping [ie overnight] so its hardly something i can spend time debugging, since there’s no chance i’ll be able to find out why its happening. |
I'm facing some issues with showing |
Have been getting random unknown interaction errors as well on |
Would someone with this issue be willing to provide a complete, runnable code sample that reproduces this issue? Its very difficult to figure out if this is even a bug or not |
@yonilerner like I've said above, simply set up an event listener that all it does is either reply or defer the interaction it receives. Let that sit for a couple hours with a good amount of interactions coming through and you should see the error. There's no reproducible code sample because it really is random |
event listener that all it does is either reply or defer the interaction it receives. Let that sit for a couple hours with a good amount of interactions coming through and you should see the error. There's no reproducible__ |
The problem here is that there isn't enough information here to actually debug anything. I recognize that people are occasionally receiving "Unknown Interaction", but that usually indicates a problem with the developer's code. Personally, I would try capturing a variety of information:
Unfortunately, until we have better concrete information with a timeline of events in a failed interaction request there isn't a ton we can do here. |
Alright thank you, I will try to get that information for you. Unfortunately it might not be very easy since my bot is using a package and it's hard to get that info from the package itself on prod, but I'll look into it |
For what it's worth, with the increasing number of times we've seen this, I decided to finally look into a bit. In djs there shouldn't be anything getting in the way of the request firing, but I am implementing a separate request handler to handle specifically interaction callbacks. While in theory this won't change the external facing behavior of the request, it at least should streamline the process and make it a little easier to debug. |
Been a few months here so I'm assuming the behavior isn't being seen anymore. |
still getting those to this day, notably from people with a bad internet connection |
Bad connection doesn't seem have any effect here all the time (please refer to my previous comment). |
This is happening more often now. Around 20+ times per day. My bot is in 41 Servers with a total of 127k Users. Mainly happens on showModal for me and sometimes on ApplicationCommand. In case of showModal even though the error is thrown, the modal still gets sent to the end user. But in case of ApplicationCommand it just straight erros the whole response. |
It's happening not only in discord.js, but in discord.net as well. |
Yea I try fix it I change my host service but it doesnt care... |
Is it fixed? I'm getting this error every time I click a button whiel I get a reply. |
This just happens randomly and lasts 15-20 minutes then gone |
I had a testbot using disnake with around 10 test users - and had been running for a couple of months. Ran into this issue a week ago and still happened today. |
I can reliably reproduce this error for my bot. As another concluded in this thread, fundamentally it's not an issue with any specific library. Discord's API is giving you an HTTP 404 because it can't find the interaction for what is very likely a legitimate reason. In my case it comes down to Node.js processing capabilities and the interaction between two of my bot's commands, one deferred and one not. I have a CPU-intensive command that constructs and attaches an image. At the high end this command can take 5 or 6 seconds. I defer this command, but due to suboptimal programming on my part the processing still blocks the event loop for the duration. If I send another one of my bot's commands--a performant one that is not deferred--Discord's API immediately starts the 3-second or so timer for my bot's reply to that one. If the event loop is blocked past that 3 second window, Discord cancels the interaction and thus it no longer exists. Some time after the event loop is unblocked and my bot attempts to reply to the non-existent interaction. HTTP 404 "unknown interaction". Below is an example. I actually sent the Personally I think for this issue to remain open, others need to provide more concrete data on why HTTP 404 is not warranted |
Im getting the same with JDA as well... What weird is that the error is being thrown in my console. But the message did actually reach discord in time. |
Still getting the same error in d.js-14.14.1. |
I see this multiple times a week on a deferred request using https://github.com/Snazzah/slash-create (yet another completely different library), on a bot that's in one server and gets ~5 requests/day. Mine's hosted on Cloudflare Workers; is it possible that some global rate limit is getting hit on a hosting provider basis? (I don't know how I would investigate that.) |
Happens to me regularly in both discord.py and nextcord. I have 70ms latency and usually respond to commands well within a second, so I think its an API issue. |
This happens to me at random times (I use discord.js) when I try to defer replies, before which there is no other time consuming processing going on. I do have ~300ms of latency so I'm not sure if it's a spike causing it, but it happens far too often in a week. |
+1 I sometimes get random Unknown Interaction errors using discord.js and discordeno as well sometimes. I've gotten to the point I use HTTP interactions as a workaround. |
Getting this issue on latest versions of JDA and Discord.JS, seems like something wrong with discord itself not any single library. |
I modified my code to repeatedly resend the failed deferred request with a 1000ms delay, and I just had 4 So at least in my case, the webhook and interaction are definitely (eventually) valid; it's not a matter of a URL being incorrect or a timeout (or a reasonable minimum time between requests being required to prevent a serverside race condition, which clients could plausibly implement; 4 seconds is way too long for that). That, to me, makes it sound very much like it is in fact a Discord-side problem (re: AlecM33's comment). |
Using JDA, with commands that are otherwise instants (a /ping command), I get this error. The weird part is that it's really random, but once it happens, it just wont go away. The command itself or my code does not seems to be a problem either since when it works, the interaction respond instantly. The device on which the code run is good, and the network is fast. I was not able to identify a pattern, unfortunately, hope it get fixed soon edit : the commands fail instantly, it does not wait 3 seconds, and when it happens, JDA dont get a SlashCommandInteractionEvent edit (8th of june, 12:00) : removing the bot from a guild and re-adding it seems to have fixed it for now ? For the record, the interactions would fail no matter the guild, or if sent through dms, and was persistent accross restarts of the app edit (10th of june, early morning) : correcting what I said two days ago, once the bug get triggered, it will only do so in existing guilds, adding it to a new guild will make commands work, but only in dms (for members of that guild) and the guild |
@marcustyphoon I still think there are probably legitimate explanations for the scenarios where this occurs, but I of course won't claim that for sure since everyone's situation is different. Since I had a 100% reliable way to reproduce the problem, I thought it would be useful to provide my explanation and more or less challenge those here, since so much of the info here is anecdotal and difficult to act on from discord's perspective. It does sound like your scenario is simple and somewhat consistent, so perhaps you could provide a minimally reproducible code example. That would probably help this gain traction in the event a maintainer checks in on this. Just personally, whenever I've run into this it's had a client-side explanation. In any case - I'm not just looking to dismiss people's troubles. Rather I hoped to facilitate since this has been open for some time. |
I have been seeing this issue ever since i first implemented slash commands over a year ago but i have largely dismissed it as being caused by network lag and interactions that arrive too late, but now I'm convinced there is an actual issue going on and decided to investigate further, so here are my two cents. My setup is as follows: I have a website that receives interactions via webhook URL, hosted on a Hetzner vps located in Ashburn US, running nginx 1.25.4 with an upstream proxy to Node.js 22.4 which runs my own custom code. Here is an example of the timings i observe multiple times per day: Sample 1
Sample 2
My conclusion: Discord is somehow not acknowledging the defer from the interaction webhook response and then delaying the follow up request until it expires. I thought about the possibility that the follow up is sent too fast, before the response from nginx is received by discord, but it doesn't seem to be the case as the issue persists even when the command takes 500ms+ to run. I hope this is useful in getting this resolved, i can provide more information and more tests if needed. (edit: formatting + typos) |
update : After more experimentation, it turned out to be a client side issue, for a reason I dont understand, reloading discord did fix it and I dont know why. Since this error seems to be generic, it wont be useful for everyone, but for people that get this error in the same way as I did, it could help edit (11 of august) : some of the users reported the exact same issue to me, the issue does not seems to appear on mobile, only desktop |
observation: you can solve the issue by deferring the response, this results in an unnecessary request (note: both defer and response happen in under a second, this is a workaround and not the intended use of defers) |
I've been experiencing this issue exclusively with commands that were already deferred. |
update: I was able to greatly reduce the number of errors by not responding to the webhook itself. My setup now is as follows:
This solution is only applicable when receiving interactions via webhook, but it seems to work well for now. |
Description
I've seen this issue reported by many people but so far no one has been able to gather enough information to reliably explain what's going on. An example can be seen at discordjs/discord.js#7005
In summary, every now and then at a seemingly random chance it's possible that a bot's reply to an interaction fails due to an Unknown Interaction when, in reality, the reply succeeded and was shown to the user (by reply I mean a regular reply, deferred reply or update). I know this because I've been investigating this issue on a bot I manage for around a week now and I asked some users who were impacted by this.
In the following screenshots I'm logging the time it took for me to reply by subtracting the current timestamp to the interaction's created_timestamp, and then logging the time it took for the bot to receive the error by subtracting the timestamp at the time the error was received to the one before the request was submitted. You can see that the reply is sent pretty fast and in time for Discord to accept it, however, the error comes 5 seconds later, indicating some sort of issue on Discord's end.
And of course I could be faking those numbers but it would make no sense for me to do that so I'm gonna have to ask you to trust that.
I later asked the user impacted by this issue to see what the bot responded with, and they showed that the reply was indeed deferred, which means that that error was a false positive and everything worked fine on our end.
Steps to Reproduce
There are no steps to consistently reproduce this issue as it only happens randomly. What I can tell is that the error comes when the API takes too long to send the response back but actually acknowledges and processes it.
Expected Behavior
The reply is sent correctly (happening) and a success message is returned
Current Behavior
The reply is sent correctly but an "Unknown Interaction" error is thrown
Screenshots/Videos
Can only attach what I've shown above already
(Bot is thinking but in Portuguese)
Client and System Information
discord.js v14.6.0 on Node v18.11.0 running on Debian 11 (bullseye)
The text was updated successfully, but these errors were encountered: