Patch LibavDemuxer to output full error stack trace for stream failures

This commit is contained in:
MiTHRAL 2026-05-26 18:13:25 -04:00
parent 4ccb769c9d
commit 072d0483bd

View file

@ -12,6 +12,25 @@ try {
// Optional in local dev when dependencies are not installed yet. // Optional in local dev when dependencies are not installed yet.
} }
try {
const fs = require("fs");
const path = require("path");
const targetPath = path.resolve(__dirname, "node_modules/@dank074/discord-video-stream/dist/media/LibavDemuxer.js");
if (fs.existsSync(targetPath)) {
let content = fs.readFileSync(targetPath, "utf8");
if (!content.includes("DEMUX ERROR STACK")) {
content = content.replace(
`loggerFrameCommon.info({ error: e }, "Received an error during frame extraction. Stopping");`,
`console.error("[DEMUX ERROR STACK]:", e && e.stack ? e.stack : e); loggerFrameCommon.info({ error: e }, "Received an error during frame extraction. Stopping");`
);
fs.writeFileSync(targetPath, content, "utf8");
console.log("[worker] Patched LibavDemuxer.js successfully to print demux error stack.");
}
}
} catch (err) {
console.error("[worker] Failed to patch LibavDemuxer.js:", err);
}
const PORT = Number(process.env.PORT || "8790"); const PORT = Number(process.env.PORT || "8790");
const TOKEN = String(process.env.WATCHPARTY_WORKER_TOKEN || "").trim(); const TOKEN = String(process.env.WATCHPARTY_WORKER_TOKEN || "").trim();
const DISCORD_USER_TOKEN = String( const DISCORD_USER_TOKEN = String(