fix(voice): screen share crashed gateway — Streamer never joined voice + unhandledRejection
Root cause: ScreenShareController created @dank074 Streamer but never called streamer.joinVoiceChannel() — playStream threw 'Bot is not connected to a voice channel', and since the code only used .finally() (no .catch), the rejection became an unhandledRejection that took down the whole gateway (graceful shutdown triggered, systemd restarted). Fixes: 1. Resolve active channel + streamer.joinVoiceChannel(channel) before prepareStream/playStream (dank074 needs its OWN WebRTC voice connection). 2. .catch() on the playStream done promise — log + kill ffmpeg instead of crashing the process. 3. .catch() on playback.done in media.handler too. 4. stop() now kills ffmpeg AND stops the streamer's voice connection.
This commit is contained in:
@@ -178,12 +178,19 @@ export class MediaHandler {
|
||||
addedAt: Date.now(),
|
||||
status: "playing",
|
||||
};
|
||||
playback.done.finally(() => {
|
||||
this.screenPlayback = null;
|
||||
if (currentTrackItem?.mode === "screen") {
|
||||
currentTrackItem = null;
|
||||
}
|
||||
});
|
||||
playback.done
|
||||
.catch((err) => {
|
||||
this.logger.error(
|
||||
{ error: err instanceof Error ? err.message : String(err) },
|
||||
"Screen playback promise rejected",
|
||||
);
|
||||
})
|
||||
.finally(() => {
|
||||
this.screenPlayback = null;
|
||||
if (currentTrackItem?.mode === "screen") {
|
||||
currentTrackItem = null;
|
||||
}
|
||||
});
|
||||
this.logger.info({ url }, "Screen share started");
|
||||
return { id: cmd.id, success: true, data: buildStatusPayload() };
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user