Androz2091 / discord-player

🎧 Complete framework to simplify the implementation of music commands using discord.js v14
https://discord-player.js.org/
MIT License
589 stars 192 forks source link

Bot crashes when the GuildQueue.delete() method is called while a song from that queue is being loaded #1909

Closed Duda02 closed 3 months ago

Duda02 commented 3 months ago

What I have is a simple leave command that calls the GuildQueue.delete() method when executed, combined with leaveOnStop: true from GuildNodeCreateOptions, it makes the bot leave the voice channel. However when the leave command is executed while a song from the queue is being loaded, a Cannot read properties of null (reading 'createStream') error is thrown.

I need some guidance if this can somehow be fixed on my side or requires an update to this package, thanks in advance!

To Reproduce

  1. Add two songs to the queue and start the playback
  2. When the first song finishes playing, call the GuildQueue.delete() method. The time window that this method can be called and will result in a crash is dependent on the song loading time, in my case it seems to be around 2 seconds.
  3. The bot will leave the channel but it will also crash

Expected behavior The bot is disconnected from the voice channel, but it doesn't crash the application.

Screenshots image

Please complete the following information:

Duda02 commented 3 months ago

I've managed to find a workaround that catches the uncaught exception and prevents the crash.

process.on('uncaughtException', (error) => {
    console.error(error);
});