This commit is contained in:
NoLogicAlan committed 2026-08-28 23:52:14 +03:00
1 parent e11fca151c
commit 9fb2e7255e
2 files changed
+23 -1

No files matched your search

+22
View File
@@ -1026,7 +1026,20 @@ const isIgnorableWsCrash = (err) => {
);
};
/**
* Check whether an error is the benign LiveKit "AudioSource is closed" race.
* Happens when a track is skipped/stopped while @fluxerjs/voice's internal
* WebM demuxer still has queued frames to push into the just-closed audio
* source. Harmless by itself — but if it ever surfaces as a synchronous
* uncaughtException it must NOT take the whole bot down.
* @param {Error} err - The error to check.
* @returns {boolean} True if the error is the audio stop-race.
*/
const isBenignAudioStopRace = (err) =>
String(err?.message ?? err ?? "").includes("AudioSource is closed");
let _lastWsCrashLog = 0;
let _lastAudioRaceLog = 0;
const WS_CRASH_LOG_COOLDOWN = 30_000;
process.on("unhandledRejection", (reason, p) => {
@@ -1043,12 +1056,21 @@ process.on("uncaughtException", (err, origin) => {
}
return;
}
if (isBenignAudioStopRace(err)) {
const now = Date.now();
if (now - _lastAudioRaceLog > WS_CRASH_LOG_COOLDOWN) {
_lastAudioRaceLog = now;
logger.warn("[Error_Handling] Suppressed benign audio stop-race (AudioSource is closed) — track was skipped/stopped mid-frame.");
}
return;
}
logger.error("[Error_Handling] Uncaught Exception/Catch");
logger.error("Error:", err, origin);
process.exit(1);
});
process.on("uncaughtExceptionMonitor", (err, origin) => {
if (isIgnorableWsCrash(err)) return;
if (isBenignAudioStopRace(err)) return;
logger.error("[Error_Handling] Uncaught Exception/Catch (MONITOR)");
logger.error("Error:", err, origin);
});
+1 -1
View File
@@ -14,7 +14,7 @@
"opusscript": "^0.0.8",
"prism-media": "^1.3.5",
"redis": "^5.12.1"
},w
},
"scripts": {
"dev": "node --inspect index.mjs --trace-warnings",
"start": "node index.mjs",