Best way to handle ready event failure

Recently my bot had a lot of downtime because it auto-restarted but never got properly readied; it seems it silently errored with a RequestAbortedError. What's the best way to handle something happening like that? When it errored it never fired the ready event and put the bot into a do-nothing limbo until I manually restarted it. Is there an event I should listen to, or just a generic timeout I should set to see if it readied properly?
6 Replies
d.js toolkit
d.js toolkit10mo 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!
treble/luna
treble/luna10mo ago
sounds like a network issue, might wanna look into that
Sukadia
Sukadia10mo ago
i did, it was because of Discord earlier
No description
Sukadia
Sukadia10mo ago
but i want to make sure it doesn't get stuck again by just giving up getting ready well i just call client.login() and it shouldn't catch any errors, but in this particular situation i got an error in my logs but it did not stop the process, which caused it just to sit and do nothing ideally it should error and restart itself (through pm2), i don't know why it did not how would i go about fixing that? i'm not sure why it'd log but not fail just pm2's default process error log
2023-08-18T08:33:29: RequestAbortedError [AbortError]: Request aborted
2023-08-18T08:33:29: at RequestHandler.abort (/root/Discord-Bots/Everyone-Votes/live/node_modules/undici/lib/client.js:1376:44)
2023-08-18T08:33:29: at abort (/root/Discord-Bots/Everyone-Votes/live/node_modules/undici/lib/api/abort-signal.js:8:10)
2023-08-18T08:33:29: at self.<computed> (/root/Discord-Bots/Everyone-Votes/live/node_modules/undici/lib/api/abort-signal.js:29:5)
2023-08-18T08:33:29: at [nodejs.internal.kHybridDispatch] (node:internal/event_target:762:20)
2023-08-18T08:33:29: at EventTarget.dispatchEvent (node:internal/event_target:704:26)
2023-08-18T08:33:29: at abortSignal (node:internal/abort_controller:365:10)
2023-08-18T08:33:29: at AbortController.abort (node:internal/abort_controller:387:5)
2023-08-18T08:33:29: at Timeout.<anonymous> (/root/Discord-Bots/Everyone-Votes/live/node_modules/@discordjs/rest/dist/index.js:778:73)
2023-08-18T08:33:29: at listOnTimeout (node:internal/timers:573:17)
2023-08-18T08:33:29: at process.processTimers (node:internal/timers:514:7) {
2023-08-18T08:33:29: code: 'UND_ERR_ABORTED'
2023-08-18T08:33:29: }
2023-08-18T08:33:29: RequestAbortedError [AbortError]: Request aborted
2023-08-18T08:33:29: at RequestHandler.abort (/root/Discord-Bots/Everyone-Votes/live/node_modules/undici/lib/client.js:1376:44)
2023-08-18T08:33:29: at abort (/root/Discord-Bots/Everyone-Votes/live/node_modules/undici/lib/api/abort-signal.js:8:10)
2023-08-18T08:33:29: at self.<computed> (/root/Discord-Bots/Everyone-Votes/live/node_modules/undici/lib/api/abort-signal.js:29:5)
2023-08-18T08:33:29: at [nodejs.internal.kHybridDispatch] (node:internal/event_target:762:20)
2023-08-18T08:33:29: at EventTarget.dispatchEvent (node:internal/event_target:704:26)
2023-08-18T08:33:29: at abortSignal (node:internal/abort_controller:365:10)
2023-08-18T08:33:29: at AbortController.abort (node:internal/abort_controller:387:5)
2023-08-18T08:33:29: at Timeout.<anonymous> (/root/Discord-Bots/Everyone-Votes/live/node_modules/@discordjs/rest/dist/index.js:778:73)
2023-08-18T08:33:29: at listOnTimeout (node:internal/timers:573:17)
2023-08-18T08:33:29: at process.processTimers (node:internal/timers:514:7) {
2023-08-18T08:33:29: code: 'UND_ERR_ABORTED'
2023-08-18T08:33:29: }
GuikiPT
GuikiPT10mo ago
or with
try {
...
}
catch (error)
console.error(error.stack || error);
}
try {
...
}
catch (error)
console.error(error.stack || error);
}
Sukadia
Sukadia10mo ago
missed these messages; yea that should definitely help. thank you!