Closed ChrisSch-dev closed 3 years ago
epipe error from the stream is forwarded to DiscordPlayer.on("error")
event so users should always listen to that event in order to prevent EPIPE error being thrown
So like
case 'error': message.channel.send('an error happened') break;
?
I use case and break for handling errors for DiscordPlayer
player.on("error", (error, message) => {
switch(error) {
case "something":
// something
break;
default: // for rest of the errors not handled above
// do something with `EPIPE`
}
})
I did exactly that.
i did
default: message.channel.send('error')
but still the same error happens, and sometimes it will even crash the bit
It wont crash your process after using .on("error")
. Discord player automatically destroys your queue when that error occurs (if it's last song, else moves to next song).
and using node.js v14 has resolved the EPIPE
error for some users, might wanna try that out?
My bot uses v14 nodejs. Sometimes it will crash my bot, sometime it will just destroy the queue if it is the last song, and move to a new song if there is a new song.
This is mt DiscordPlayer error.js file, maybe there is smth that Im doing wrong?
module.exports = (client, error, message) => {
switch (error) {
case 'NotPlaying':
message.channel.send(${client.emotes.error} - There is no music being played on this server !
);
break;
case 'NotConnected':
message.channel.send(${client.emotes.error} - You are not connected in any voice channel !
);
break;
case 'UnableToJoin':
message.channel.send(${client.emotes.error} - I am not able to join your voice channel, please check my permissions !
);
break;
case 'ParseError':
message.channel.send(${client.emotes.error} - Something went wrong while parsing the audio!
)
break;
case 'VideoUnavailable':
message.channel.send(${client.emotes.error} - This video is unavailable! Please selecta different song!
)
break;
case 'MusicStarting':
message.channel.send(${client.emotes.error} - Music Player is starting... Please wait!
)
break;
default:
message.channel.send(${client.emotes.error} - Something went wrong while executing the requested action...\n\
``\n${error}\n````);
};
};
Here is the code I use for my bot and it does not crash the bot. Before, this error caused the nodejs process to completely crash which would also take the bot offline. It wont happen now
I see. Also If you are wondering, this error exist in 4.0.0 or higher. In 3.4.0 this error does not exist.
Also my bot is also using PM2 so maybe its related to pm2?
what do you mean? your bot completely restarts with that error?
After it crashes, it reboots.
I tried your code, still, it will sometimes crash my bot, if it doesn't crash the bot, it wouldn't even send the error message. Please add a dedicated error handler in Player#error for EPIPE
After it crashes, it reboots.
This is not related to the error but with PM2, I also use PM2 and when there's an error PM2 will restart the application.
I tried your code, still, it will sometimes crash my bot, if it doesn't crash the bot, it wouldn't even send the error message. Please add a dedicated error handler in Player#error for EPIPE
About this, I think this is not an error 100% related to discord-player but with nodeJS
dont know what you mean by the dedicated error handler
. We are already forwarding the error
event for epipes aka handling the error on our side. Users will have to handle the forwarded error emitted by Player.on("error")
on their side.
It's a node.js feature to exit the process if there is no event listener for the error
event (You can read more here: Node.js#events_error_events)
If an
EventEmitter
does not have at least one listener registered for the'error'
event, and an'error'
event is emitted, the error is thrown, a stack trace is printed, and the Node.js process exits.
but I will still try my best to find the issue because I might have done something wrong from my side 👍🏼
Is your feature request related to a problem? Please describe. I requested this feature due to the Write EPIPE error that happens, that can crash your bot (It may crash your bot)
Describe the solution you'd like Add an dedicated error handler for Write EPIPE to Player#error