discord.js occasionally resending requests, causing double messages

I've got a feature which sends a message at 00:00:00. However, sometimes requests are sent twice or even three times. This doesn't affect only messages, a PUT Guild Member request was also re-send once. I'm quite sure this isn't a code issue, and it might very well not be related to djs (probably just too many network requests at that time). Sample Timeline (ms) T+0: djs correctly sends the Birthday message request M1 T+194: Discord assigns a snowflake to M1 (probably near the sent timestamp in the channel) T+302: Guild Member request is sent P1 T+15_002: Birthday message request M1 fails; without status, headers and body*; djs resends it M2 T+15_303: Guild Member request P1 fails, same response as above; djs resends it P2 T+15_364: Discord assigns a snowflake to either P1 or P2 T+15_458: Guild Member request triggers a Guild Member update event (either P1 or P2) T+15_673: Discord assigns a snowflake to M2 T+16_012: HTTP 200 and message body returned for M2 T+16_224: HTTP 204 returned for P2 *: probably a network error? I'm currently unable to log those with my hack-ish request logging Main issue Despite the requests failing to return a proper response, causing djs to resend them, they are processed correctly on Discords end. This doesn't really matter for e.g. Guild Member updates, but messages being sent two or three times is just annoying. So, what's causing djs to retry requests, or is this unrelated to djs and done at undici level or below? Version: discord.js@14.15.3-dev.1716595781-a468ae8bb (not latest, tho it happened four months ago already so unlikely to be a recent issue)
3 Replies
d.js toolkit
d.js toolkit4mo ago
- 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! - Marked as resolved by OP
GitHub
GitHub4mo ago
:issue_open: #10301 in discordjs/discord.js by wisienak opened <t:1716698508:R> Bot send embed messages twice or even triple times after being not used for a while
TomatoCake
TomatoCake4mo ago
Oh, I've searched for GH issues but apparently only with the wrong keywords, I'm sorry Nonce enforcing does sound good, is there a way (planned) of making djs able to handle that? Generating them on my end seems wrong (mainly because I use <Channel>.send() everywhere, and all of those would need two additional properties) Yea no that's ofc not a good as default enabled, but maybe as option for the REST client? Should I create a feature request for that to be added? And regardless, thank you (and all other contributors) for maintaining this lib and helping me xd
a random nonce: (use SnowflakeUtil.generate() for example)
just fyi: that function returns a BigInt which isn't accepted as nonce. Could be another feature request xD ... Yea I stopped reading after kyranets reply I thought about automatically calling .toString() on BigInts for nonce which would happen in djs, not returning a string as Snowflake I was about to blame you for accepting both numbers and strings, but that's Discords fault. Nevermind then.
Want results from more Discord servers?
Add your server