The operation was aborted

My bot successfully connects to channels, then tries to await entersState(connection, VoiceConnectionStatus.Ready, 15e3); but for some channels it enters to the Ready state successfully while for others the following error is got: AbortError: The operation was aborted at EventTarget.abortListener (node:events:993:14) at [nodejs.internal.kHybridDispatch] (node:internal/event_target:741:20) at EventTarget.dispatchEvent (node:internal/event_target:683:26) at abortSignal (node:internal/abort_controller:368:10) at AbortController.abort (node:internal/abort_controller:402:5) at Timeout.<anonymous> (/home/cmp-name/my-app/node_modules/@discordjs/voice/dist/index.js:2504:39) at listOnTimeout (node:internal/timers:569:17) at process.processTimers (node:internal/timers:512:7) My code: export async function join(channel: VoiceBasedChannel) { const connection = joinVoiceChannel({ channelId: channel.id, guildId: channel.guild.id, selfDeaf: false, selfMute: true, adapterCreator: channel.guild.voiceAdapterCreator as unknown as DiscordGatewayAdapterCreator, debug: true }); connection.setMaxListeners(100); connection.on('debug', (message) => { log.debug(Debug message for the ${channel.guild.id} guild: ${message}); }); connection.on('error', (error) => { log.error(Error for the ${channel.guild.id} guild: ${error}); }); log.debug(Connection to the ${channel.guild.id}[${channel.id}] voice channel was created successfully); try { await entersState(connection, VoiceConnectionStatus.Ready, 15e3); return true; } catch (error: any) {
throw error; } } discord.js: 14.11.0 discordjs/voice: 0.16.0 node: 18.17.0
7 Replies
d.js toolkit
d.js toolkit2mo 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!
ThePedroo
ThePedroo2mo ago
If that happens while playing, it's normal A lot of CDNs have a timeout, so you have to buffer what you receive in a intermediary buffer/stream Oh nvm ig Also, by throwing in catch of try-catch, you're entirely going against what it is made for
Chiko0401
Chiko04012mo ago
@Qjuh Is it truly related to certain channels? - What do you mean certain channels? It happens on the client's servers. What are channel settings can cause it? @Qjuh Or could it be because the bot already was connected to another VC on that same guild before (and thus the connection already was ready and won’t enter that state again)? - No, I check first if the bot is in any channel in the same guild then ignore this event and don't connect @ThePedroo It happens on entering to the Ready state. Why try-catch against what it is made for? @Qjuh I see, I didn't explain correct. It can happen for the same channel. I checked it now in logs and I see that for the same channel the bot got the Abort error than two minutes after it successfully joined to this channel
ThePedroo
ThePedroo2mo ago
Primarily made for programs that shouldn't exit You can also use it to modify the error, but you're not doing that, you're just throwing it plainly so..
Chiko0401
Chiko04012mo ago
@Qjuh Could it be connection issues and I need to do retries? Is it built-in functionality?
Chiko0401
Chiko04013w ago
@Qjuh I added debug details here - https://github.com/discordjs/discord.js/issues/10356
GitHub
Bot can't enter the ready state in voice channels · Issue #10356 · ...
Which package is this bug report for? discord.js Issue description We have noticed that our bot gets the timeout error ~30-40 times a day (against 60-70 successful connections): Error stack: AbortE...
Chiko0401
Chiko04013w ago
@Qjuh In the case IP discovery fails, Discord throws the "Cannot perform IP discovery - socket closed" message in the error. Here the message text is "AbortError: The operation was aborted". I don't know if it important. Regarding more time - yesterday I added retries, it didn't help unfortunately. I will increase timeout to 30s