mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
test
This commit is contained in:
1 parent
b031cbaeaf
commit
cc9bffe8c9
2 files changed
+28
-9
No files matched your search
@@ -963,6 +963,11 @@ class Remix {
|
|||||||
const guildId = player._guildId;
|
const guildId = player._guildId;
|
||||||
if (!guildId) continue;
|
if (!guildId) continue;
|
||||||
|
|
||||||
|
// Skip if player is mid-join or mid-recovery — _is247Enabled() and
|
||||||
|
// _channelId/_guildId may not be populated yet, causing a false
|
||||||
|
// "not 247" result that immediately leaves a freshly spawned 247 player.
|
||||||
|
if (player._isJoining || player._isRecovering) continue;
|
||||||
|
|
||||||
// Skip if 247 is on or auto
|
// Skip if 247 is on or auto
|
||||||
if (player._is247Enabled()) continue;
|
if (player._is247Enabled()) continue;
|
||||||
|
|
||||||
|
|||||||
+23
-9
@@ -453,15 +453,18 @@ export default class Player extends EventEmitter {
|
|||||||
// ═══════════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
async _recoverConnection() {
|
async _recoverConnection() {
|
||||||
// bail immediately if the player has been destroyed
|
// bail immediately if the player has been destroyed or a recovery is
|
||||||
if (this._isRecovering || this._destroyed) return;
|
// already in-flight or scheduled (covers the gap between attempts).
|
||||||
|
if (this._isRecovering || this._recoveryPending || this._destroyed) return;
|
||||||
this._isRecovering = true;
|
this._isRecovering = true;
|
||||||
|
this._recoveryPending = true;
|
||||||
|
|
||||||
this._recoveryAttempts = (this._recoveryAttempts ?? 0) + 1;
|
this._recoveryAttempts = (this._recoveryAttempts ?? 0) + 1;
|
||||||
const MAX_RECOVERY = 5;
|
const MAX_RECOVERY = 5;
|
||||||
if (this._recoveryAttempts > MAX_RECOVERY) {
|
if (this._recoveryAttempts > MAX_RECOVERY) {
|
||||||
logger.error(`[Player] Recovery failed after ${MAX_RECOVERY} attempts for guild ${this._guildId} — giving up.`);
|
logger.error(`[Player] Recovery failed after ${MAX_RECOVERY} attempts for guild ${this._guildId} — giving up.`);
|
||||||
this._isRecovering = false;
|
this._isRecovering = false;
|
||||||
|
this._recoveryPending = false;
|
||||||
this._recoveryAttempts = 0;
|
this._recoveryAttempts = 0;
|
||||||
this.emit("autoleave");
|
this.emit("autoleave");
|
||||||
return;
|
return;
|
||||||
@@ -489,13 +492,14 @@ export default class Player extends EventEmitter {
|
|||||||
logger.mediaplayer(`[Player] Rejoining channel ${this._channelId}`);
|
logger.mediaplayer(`[Player] Rejoining channel ${this._channelId}`);
|
||||||
await this.join(this._channelId);
|
await this.join(this._channelId);
|
||||||
|
|
||||||
const roomState = this.connection?.room?.state;
|
// Do NOT re-read room.state here — on this LiveKit build room.state
|
||||||
const isConnected = roomState === 1 || roomState === "connected" || roomState === "connecting";
|
// returns undefined even on a healthy connection (not persistently stored).
|
||||||
if (!isConnected) {
|
// join() already awaited connectionStateChanged and only resolved when
|
||||||
throw new Error(`Room in unexpected state after rejoin: ${roomState}`);
|
// the room was truly connected, so reaching this line means success.
|
||||||
}
|
// The old room.state check here always threw "unexpected state: undefined"
|
||||||
|
// and emitted autoleave, causing the infinite reconnect storm in the logs.
|
||||||
this._isRecovering = false;
|
this._isRecovering = false;
|
||||||
|
this._recoveryPending = false;
|
||||||
this._recoveryAttempts = 0;
|
this._recoveryAttempts = 0;
|
||||||
|
|
||||||
const current = this.queue.getCurrent();
|
const current = this.queue.getCurrent();
|
||||||
@@ -512,7 +516,17 @@ export default class Player extends EventEmitter {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error("[Player] Recovery failed:", e.message);
|
logger.error("[Player] Recovery failed:", e.message);
|
||||||
this._isRecovering = false;
|
this._isRecovering = false;
|
||||||
this.emit("autoleave");
|
// _recoveryPending stays true during the retry delay to block duplicate
|
||||||
|
// calls from stacking up (e.g. two rapid disconnect events).
|
||||||
|
if (!this._destroyed && !this.leaving) {
|
||||||
|
const delay = Math.min(2000 * (this._recoveryAttempts ?? 1), 30_000);
|
||||||
|
setTimeout(() => {
|
||||||
|
this._recoveryPending = false;
|
||||||
|
if (!this._destroyed && !this.leaving) this._recoverConnection();
|
||||||
|
}, delay);
|
||||||
|
} else {
|
||||||
|
this._recoveryPending = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user