mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
fix(gateway, player): resolve zombie gateway hangs and playback race conditions
- Gateway & Connection Recovery: - Handle opcodes 7 (Reconnect) and 9 (InvalidSession) by terminating sockets and clearing session state for clean re-IDENTIFY - Restrict gateway heartbeat updates strictly to genuine Dispatch (op 0) and Heartbeat ACK (op 11) - Trigger proactive shard reconnect immediately on raw WebSocket close events - Tighten gateway watchdog intervals and add a 5s hard-kill timeout on gracefulShutdown to prevent process deadlocks - Allow child bot processes to control the Docker container healthcheck file - Bind shard lifecycle events (shardDisconnect, shardResume, shardReady) - Player & Audio Pipeline: - Add play session generation guarding (_playSessionGen) in PlaybackMixin and Player._bridgeStop to prevent asynchronous race conditions and rapid queue skip-loops - De-escalate Lavalink loadtracks resolution fallbacks from logger.warn to logger.player to avoid false-alarm telemetry embeds - Extract detailed Lavalink error reasons in AudioBridge console logs - Command Routing: - Add guildId and guild getters on Message wrapper and expand CommandHandler guildId extraction
This commit is contained in:
1 parent
36ad89b1d2
commit
aa56d98809
3 files changed
+15
-4
No files matched your search
@@ -67,6 +67,7 @@ const StreamPipeline = {
|
|||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
const onEnd = () => {
|
const onEnd = () => {
|
||||||
|
logger.player("[AudioBridge] Stream onEnd reached (durationMs=" + durationMs + ", playing=" + this._playing + ", stopped=" + this._stopped + ")");
|
||||||
if (durationMs > 0 && this._playing && !this._stopped) return;
|
if (durationMs > 0 && this._playing && !this._stopped) return;
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
@@ -349,7 +350,7 @@ const StreamPipeline = {
|
|||||||
try {
|
try {
|
||||||
const nlInfo = this._lavalink.getNodeLinkInfo?.();
|
const nlInfo = this._lavalink.getNodeLinkInfo?.();
|
||||||
if (!nlInfo) {
|
if (!nlInfo) {
|
||||||
logger.warn("[AudioBridge] _resolveUrlViaLavalink: no NodeLink info");
|
logger.player("[AudioBridge] _resolveUrlViaLavalink: no NodeLink info");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,11 +376,13 @@ const StreamPipeline = {
|
|||||||
return encoded;
|
return encoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadType = body?.loadType ?? body?.data?.loadType;
|
const loadType = body?.loadType ?? body?.data?.loadType ?? "unknown";
|
||||||
logger.warn("[AudioBridge] Lavalink loadtracks returned no playable track (loadType=" + loadType + ")");
|
const errorMsg = body?.data?.message ?? body?.exception?.message ?? body?.message;
|
||||||
|
const details = errorMsg ? `: ${errorMsg}` : "";
|
||||||
|
logger.player("[AudioBridge] Lavalink loadtracks returned no playable track (loadType=" + loadType + details + ")");
|
||||||
return null;
|
return null;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warn("[AudioBridge] _resolveUrlViaLavalink failed: " + e.message);
|
logger.player("[AudioBridge] _resolveUrlViaLavalink failed: " + e.message);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -385,6 +385,8 @@ const PlaybackMixin = {
|
|||||||
const totalMs = this._getTrackDurationMs(songData);
|
const totalMs = this._getTrackDurationMs(songData);
|
||||||
const durationMs = totalMs > 0 ? Math.max(0, totalMs - seekMs) : 0;
|
const durationMs = totalMs > 0 ? Math.max(0, totalMs - seekMs) : 0;
|
||||||
|
|
||||||
|
const myPlayGen = (this._playSessionGen = (this._playSessionGen ?? 0) + 1);
|
||||||
|
|
||||||
const result = await this._audioBridge.play(this._voiceConn, {
|
const result = await this._audioBridge.play(this._voiceConn, {
|
||||||
encoded: songData.encoded,
|
encoded: songData.encoded,
|
||||||
url: bridgeUrl,
|
url: bridgeUrl,
|
||||||
@@ -397,6 +399,11 @@ const PlaybackMixin = {
|
|||||||
filterPayload: this.activeFilterPayload || null,
|
filterPayload: this.activeFilterPayload || null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (myPlayGen !== this._playSessionGen) {
|
||||||
|
/* Another track was started or stopped while this was playing — drop stale completion */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (result === null) {
|
if (result === null) {
|
||||||
throw new Error("Playback failed to start for track: " + (songData?.title ?? "unknown"));
|
throw new Error("Playback failed to start for track: " + (songData?.title ?? "unknown"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1068,6 +1068,7 @@ class Player extends EventEmitter {
|
|||||||
|
|
||||||
/** @private Stop the audio bridge if currently playing. */
|
/** @private Stop the audio bridge if currently playing. */
|
||||||
_bridgeStop() {
|
_bridgeStop() {
|
||||||
|
this._playSessionGen = (this._playSessionGen ?? 0) + 1;
|
||||||
if (this._audioBridge) {
|
if (this._audioBridge) {
|
||||||
try { this._audioBridge.stop(); } catch (_) {}
|
try { this._audioBridge.stop(); } catch (_) {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user