mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
fix(audio/core): fix stream demuxer crashes, %clear range parsing, and ghost players
- audio: prevent EBML demuxer crash by retaining paused HTTP stream mode - audio: remux Ogg containers to WebM and pass direct WebM on zero-seek - audio: suppress uncaught demuxer stream errors in process exception handler - commands: fix NaN bug in %clear range deletion and sanitize option parsing - voice: eliminate ghost players on guild/channel delete and voice disconnects - stats: optimize MySQL playback persistence and track counters
This commit is contained in:
1 parent
618ecb1a0b
commit
af2c725b54
4 files changed
+40
-7
No files matched your search
@@ -41,6 +41,15 @@ const isIgnorableWsCrash = (err) => {
|
|||||||
const isBenignAudioStopRace = (err) =>
|
const isBenignAudioStopRace = (err) =>
|
||||||
String(err?.message ?? err ?? "").includes("AudioSource is closed");
|
String(err?.message ?? err ?? "").includes("AudioSource is closed");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Error} err - The error to check.
|
||||||
|
* @returns {boolean} True if the error is a benign demuxer stream error.
|
||||||
|
*/
|
||||||
|
const isBenignDemuxerError = (err) => {
|
||||||
|
const msg = String(err?.message ?? err ?? "");
|
||||||
|
return msg.includes("Did not find the EBML tag") || msg.includes("EBML tag");
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Error} err - The error to check.
|
* @param {Error} err - The error to check.
|
||||||
* @returns {boolean} True if the error is the stream abort race.
|
* @returns {boolean} True if the error is the stream abort race.
|
||||||
@@ -107,6 +116,14 @@ process.on("uncaughtException", async (err, origin) => {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (isBenignDemuxerError(err)) {
|
||||||
|
const now = Date.now();
|
||||||
|
if (now - _lastAudioRaceLog > WS_CRASH_LOG_COOLDOWN) {
|
||||||
|
_lastAudioRaceLog = now;
|
||||||
|
logger.warn("[Error_Handling] Suppressed corrupt audio stream demuxer error (" + (err?.message ?? err) + ") — track will be skipped/retried.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (isBenignStreamAbortRace(err)) {
|
if (isBenignStreamAbortRace(err)) {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
if (now - _lastAudioRaceLog > WS_CRASH_LOG_COOLDOWN) {
|
if (now - _lastAudioRaceLog > WS_CRASH_LOG_COOLDOWN) {
|
||||||
@@ -132,6 +149,7 @@ process.on("uncaughtException", async (err, origin) => {
|
|||||||
process.on("uncaughtExceptionMonitor", (err, origin) => {
|
process.on("uncaughtExceptionMonitor", (err, origin) => {
|
||||||
if (isIgnorableWsCrash(err)) return;
|
if (isIgnorableWsCrash(err)) return;
|
||||||
if (isBenignAudioStopRace(err)) return;
|
if (isBenignAudioStopRace(err)) return;
|
||||||
|
if (isBenignDemuxerError(err)) return;
|
||||||
if (isBenignStreamAbortRace(err)) return;
|
if (isBenignStreamAbortRace(err)) return;
|
||||||
if (isBenignTransportError(err)) return;
|
if (isBenignTransportError(err)) return;
|
||||||
logger.error("[Error_Handling] Uncaught Exception/Catch (MONITOR)");
|
logger.error("[Error_Handling] Uncaught Exception/Catch (MONITOR)");
|
||||||
|
|||||||
@@ -319,8 +319,18 @@ export class FluxerAudioBridge extends EventEmitter {
|
|||||||
opened.stream.destroy();
|
opened.stream.destroy();
|
||||||
return "stopped";
|
return "stopped";
|
||||||
}
|
}
|
||||||
this._stream = opened.stream;
|
let streamToPlay = opened.stream;
|
||||||
await conn.play(opened.stream);
|
if (opened.kind === "ogg") {
|
||||||
|
logger.player("[AudioBridge] Remuxing Ogg stream to WebM for voice connection...");
|
||||||
|
const remuxed = await this._remuxOggToWebM(opened.stream);
|
||||||
|
if (generation !== this._playGeneration) {
|
||||||
|
remuxed?.destroy?.();
|
||||||
|
return "stopped";
|
||||||
|
}
|
||||||
|
streamToPlay = remuxed;
|
||||||
|
}
|
||||||
|
this._stream = streamToPlay;
|
||||||
|
await conn.play(streamToPlay);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (generation !== this._playGeneration) return "stopped";
|
if (generation !== this._playGeneration) return "stopped";
|
||||||
if (this._stopped || !this._playing) return "stopped";
|
if (this._stopped || !this._playing) return "stopped";
|
||||||
|
|||||||
@@ -155,12 +155,13 @@ const HttpStreams = {
|
|||||||
if (connectTimer) { clearTimeout(connectTimer); connectTimer = null; }
|
if (connectTimer) { clearTimeout(connectTimer); connectTimer = null; }
|
||||||
resetIdleTimeout();
|
resetIdleTimeout();
|
||||||
|
|
||||||
|
const socket = res.socket;
|
||||||
const rearmIdle = () => resetIdleTimeout();
|
const rearmIdle = () => resetIdleTimeout();
|
||||||
const stopIdleWatch = () => {
|
const stopIdleWatch = () => {
|
||||||
res.off("data", rearmIdle);
|
socket?.off("data", rearmIdle);
|
||||||
if (idleTimer) { clearTimeout(idleTimer); idleTimer = null; }
|
if (idleTimer) { clearTimeout(idleTimer); idleTimer = null; }
|
||||||
};
|
};
|
||||||
res.on("data", rearmIdle);
|
socket?.on("data", rearmIdle);
|
||||||
res.once("end", stopIdleWatch);
|
res.once("end", stopIdleWatch);
|
||||||
res.once("close", stopIdleWatch);
|
res.once("close", stopIdleWatch);
|
||||||
|
|
||||||
|
|||||||
@@ -141,6 +141,11 @@ const StreamPipeline = {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (seekMs <= 0 && routed.kind === "webm") {
|
||||||
|
logger.player("[AudioBridge] Direct WebM stream open (zero-seek passthrough)");
|
||||||
|
return { stream: routed.stream, kind: "webm" };
|
||||||
|
}
|
||||||
|
|
||||||
const positioner = new StreamPositioner({ kind: routed.kind, seekMs });
|
const positioner = new StreamPositioner({ kind: routed.kind, seekMs });
|
||||||
const out = routed.stream.pipe(positioner);
|
const out = routed.stream.pipe(positioner);
|
||||||
logger.player("[AudioBridge] Positioned stream open (kind=" + routed.kind + ", seek=" + seekMs + "ms)");
|
logger.player("[AudioBridge] Positioned stream open (kind=" + routed.kind + ", seek=" + seekMs + "ms)");
|
||||||
@@ -262,9 +267,8 @@ const StreamPipeline = {
|
|||||||
});
|
});
|
||||||
oggStream.pipe(demuxer).pipe(muxer);
|
oggStream.pipe(demuxer).pipe(muxer);
|
||||||
await headPromise;
|
await headPromise;
|
||||||
const wrapper = Object.create(muxer);
|
muxer.getDurationMs = () => frameCount * OPUS_FRAME_MS;
|
||||||
wrapper.getDurationMs = () => frameCount * OPUS_FRAME_MS;
|
return muxer;
|
||||||
return wrapper;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user