Recurring "Cannot send an empty message" error
Hello, I'm intermittently getting hit with 50006 "Cannot send an empty message" errors in a production environment using discord.js. I can't seem to find any pattern aside from the fact that it occurs when sending attachments, specifically text files I've created server-side. Simply running a command multiple times will sometimes succeed and sometimes fail. Any ideas as to why this could be happening?!
70 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!Hello
Here is the full error:
The code is a bit complex and spans multiple files/functions, but in the end the important part is:
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Hello
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
I'm.here to help
The issue occurs without embeds as well (even if that parameter isn't provided)
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
??
Agreed! and this only started happening suddenly without any noticeable cause
The production environment also has the same dependency and node versions
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Dependencies:
Node:
v22.4.1
Bun: 1.1.20
(not actually sure if that is the same in production now that I think about it)
I've also tested without bufferutil and utf-8-validate, though the issue persistedUnknown User•6mo ago
Message Not Public
Sign In & Join Server To View
I'm here to helpppppp
You could be totally right, I'll try to get the version info!
You clearly aren't, please stop
Whatttttt
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Is not really
What
Because you're lying
I'm not doing anything to you
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Sorry yes, meant to reply to that. There are some things that seem to make it occur like big attachments, but it doesn't always occur. It seemed like the first time it sometimes went through, and then not after that (though that wasn't always the case)
It happens in many other situations, like when sending attachments copied from other messages (though that was fixed by passing the attachment.url value), and in many other scenarios with bot-generated files
Where is the error?
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
bun appears to be at
v1.1.8
in production, but I can't imagine that could be the issueUnknown User•6mo ago
Message Not Public
Sign In & Join Server To View
I don't know what the exact error is
The only errors I can fix are 404 but in this case I don't see the not found error
I have been for a few weeks, and it is all just random cases of generated text files trying to be sent with embeds. I can try to go back in the log history and check it out
Please stop. If you cannot help this error (which is not a 404) then you are contributing nothing to this thread
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
I can do that, but I'm going to quickly downgrade bun on my machine to check if that could be the cause, though unlikely
Why you behave like this I really don't understand
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Probably not, just grasping at straws at this point I think! I'll push a change and try to log some more errors
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Sorry yes, misspoke, will do!
The error is in the first post of the thread, and in https://discord.com/channels/222078108977594368/1262555432728264724/1262555573346500769
Are you able to help?
The error is 400 not 404
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Its both
The HTTP status code is 400, the Discord error code is 50006
So, since you're here to help, are you able to help?
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
But is not 404
Yes, I'm very well aware of that
So you admit that you cannot help?
?
In that case, I will again ask you to leave this thread and allow gwapes to continue helping this user
Bruh
Here's an example:
Embed:
Attachment:
I can send the whole buffer but I doubt that would be helpful
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Yep
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
And not all the time! I just edited the message three times, it errored twice and succeeded once
Which it why I just have no clue where to go from here!!!
Do you have a messageUpdate listener that logs changes in content?
I do, yes - sorry, should have clarified
It might be trying to log the embed being rendered. The error might not be coming from this code at all?
Not sure if I understand you correctly, but the embed and attachment are sent in the same message
What I mean is, sending an embed actually causes Discord to fire a messageUpdate event too
Or does it not send at all
Ah, I see what you mean, though the listener does return if it doesn't detect a content change
ahh no worries then, should already be handled
Though yes, it doesn't send at all in some scenarios
Yeah, I believe it is totally unrelated to the code, I think it has to be an API issue atp
I've changed the code to just send the attachment, though that didn't have any effect on if the message sends successfully or not
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Even sending one message with the embed and attachment and then another immediately after with the exact same attachment sometimes failed in either one or both cases
I guess I will, and pray advaith swings by haha
Thank you both for your help!! 😅
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Will do!
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
AttachmentBuilder is not async
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
The AttachmentBuilder is not buffering...
It can accept a Buffer as the file data
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
might not the API as I cannot reproduce it locally, but what it would be I'm not sure
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
nope, still haven't heard/figured out anything :/