Deferrals
I've had a few issues as I have started to try and learn deferring and avoiding timeout errors. Many scripts that worked before now only work half the time. Often I get the discord API error for 10062 which I understand means it usually took longer than 3 seconds to respond, then it times out. I also am self hosting this bot for testing purposes and have a less than optimal connection. However, all these commands worked fine previously so I want to make sure its not something in my amateur code.
More than anything Im just wanting to verify whether or not Im approaching this correctly or if its a strange issues because of my subpar connection speeds.
Ive been through the documentation and cant seem to find what I'm doing wrong, if anything at all. I've tried a few variations of things, sometimes with half sucess, but this is an example code thats having the problem right now and crashing for the api 10062 error:
12 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!Unknown User•15mo ago
Message Not Public
Sign In & Join Server To View
It scans a collection in my database to see if the user has any associated information so Im guessing that may be it. Im relatively new to this, so are you saying to run the deferReply before the try block or to just remove the await from the initial defer altogether?
Unknown User•15mo ago
Message Not Public
Sign In & Join Server To View
OH WAIT. Sorry, like I said, new. I see what you're saying. I need to defer it before I declare that constant which checks my database...right?
Unknown User•15mo ago
Message Not Public
Sign In & Join Server To View
Thank you, Im still trying to catchup and learn to use proper terminology. I appreciate the breakdown. 🙂 Im gonna try a few things with that. Even if Im self hosting with my slow connection, everything should still go through without the 10062 if I set it up properly, right?
Unknown User•15mo ago
Message Not Public
Sign In & Join Server To View
Absolutely, I appreciate the advice on best practices. Just frutsrating trying to learn how to diagnose whether is a user issue or network issue on my end lol. (90% of the time its me 😛 )
Unknown User•15mo ago
Message Not Public
Sign In & Join Server To View
Just wanted to pop back and let you know everything seems smoother now. It never clicked with me the await was taking the time up even though that makes perfect sense. Thanks again for helping a rookie out 🙂