bot spawning multiple instances of the same shard and rate limiting
never had this issue so pardon my idiocy but bot spawns more than one instance and then i get an unhandledprmiserejection that after logging i found to be a 429 too many requests which i believe is due to the multiple instances logging in. if i use a command, i get discord API err that there's an unknown interaction. if u can help i will kiss u thx (/j)
18 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!node version is latest stable update (v 18.17)
if it's the fact that everything is logging twice that makes you think more than one instance is spawned, you should take note of the fact that you listen to the
debug
event twice
I only see 1 shard spawned
i get an unhandledprmiserejection that after logging i found to be a 429 too many requestsgiven that you haven't set anything to reject on rate limit, I'm unsure whether this is even from the discord api consider actually showing the error
if i use a command, i get discord API err that there's an unknown interaction
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 responsestwo processes handling the same command
two processes handling the same command is not the only cause of "Unknown interaction"
how have you determined that this in particular is the case?
response took literally less than a second to spawn + no issue w collectors as i use interactionCreate event, don’t use msg intent, no buttons, etc
I don't see why that means you have two processes handling the same command
you only have as many logs as you would for 1 process, so unless you have another terminal open with your bot running, I'm far more inclined to believe you only have one process
okay, then is the "launched shard 0" without a logout and logging in multiple times not multiple instances? removed the second debug listener, thank u for catching that /gen
Does your node version appear more than once?
yes ;;
i don't know where the code is looping <:hy_stressedd:686506166939025417>
or what's causing it to etc
Are you requiring your shard manager in any other files?
no
then just curious, why are you exporting
getConnection
from the file your ShardingManager
is in?i just edited that (exports pool instead since i use pool.query to handle and release connections), should i be starting my sql in a different file? i didn't code it in my bot.js to avoid creating too many connections from sharding
but now that i think about it
i should be pooling per shard
shouldnt i
ok but if you're exporting
getConnection
from this file, would you not be importing this file somewhere in your bot's code?
this train of thought led me to actually check what would happen if you attempted to run a sharding manager from a single shard
this produced an extra 429 that isn't handled by djs's queueing (presumably because it's not being thrown from the Client
itself)
could you share this 429 error you were receiving?i don't think i imported it anywhere since i was toying around with everything <:shib_pain:895553033709191198> however i moved the pool creation to bot.js and i'm no longer looping, but application doesnt respond and i get no error but every command is registered fml
i can't recreate the 429 now since moving things around
which means it was prob my db
<a:KEK_mike:983456760444624896>
jk zzz i fixeed everything thank u guys for reviving my remaiing brain cells