web/task-manager/runner: proper error codes, remove debug logging

This commit is contained in:
wukko 2025-05-14 15:34:40 +06:00
parent 9d129bc865
commit 4a6f159e06
No known key found for this signature in database
GPG Key ID: 3E30B3F26C7B4AA2
2 changed files with 3 additions and 15 deletions

View File

@ -11,8 +11,6 @@ export const runFetchWorker = async (workerId: string, parentId: string, url: st
const unsubscribe = queue.subscribe((queue: CobaltQueue) => { const unsubscribe = queue.subscribe((queue: CobaltQueue) => {
if (!queue[parentId]) { if (!queue[parentId]) {
// TODO: remove logging
console.log("worker's parent is gone, so it killed itself");
killWorker(worker, unsubscribe); killWorker(worker, unsubscribe);
} }
}); });

View File

@ -34,22 +34,16 @@ export const runFFmpegWorker = async (
startAttempts++; startAttempts++;
if (startAttempts <= 10) { if (startAttempts <= 10) {
killWorker(worker, unsubscribe, startCheck); killWorker(worker, unsubscribe, startCheck);
console.error("worker didn't start after 5 seconds, so it was killed and started again");
return await runFFmpegWorker(workerId, parentId, files, args, output, variant); return await runFFmpegWorker(workerId, parentId, files, args, output, variant);
} else { } else {
killWorker(worker, unsubscribe, startCheck); killWorker(worker, unsubscribe, startCheck);
console.error("worker didn't start after 10 attempts, so we're giving up"); return itemError(parentId, workerId, "queue.worker_didnt_start");
// TODO: proper error code
return itemError(parentId, workerId, "worker didn't start");
} }
} }
}, 500); }, 500);
const unsubscribe = queue.subscribe((queue: CobaltQueue) => { const unsubscribe = queue.subscribe((queue: CobaltQueue) => {
if (!queue[parentId]) { if (!queue[parentId]) {
// TODO: remove logging
console.log("worker's parent is gone, so it killed itself");
killWorker(worker, unsubscribe, startCheck); killWorker(worker, unsubscribe, startCheck);
} }
}); });
@ -64,11 +58,10 @@ export const runFFmpegWorker = async (
}); });
worker.onerror = (e) => { worker.onerror = (e) => {
console.error("ffmpeg worker exploded:", e); console.error("ffmpeg worker crashed:", e);
killWorker(worker, unsubscribe, startCheck); killWorker(worker, unsubscribe, startCheck);
// TODO: proper error code return itemError(parentId, workerId, "queue.generic_error");
return itemError(parentId, workerId, "internal error");
}; };
let totalDuration: number | null = null; let totalDuration: number | null = null;
@ -79,9 +72,6 @@ export const runFFmpegWorker = async (
clearInterval(startCheck); clearInterval(startCheck);
// temporary debug logging
console.log(JSON.stringify(eventData, null, 2));
if (eventData.progress) { if (eventData.progress) {
if (eventData.progress.duration) { if (eventData.progress.duration) {
totalDuration = eventData.progress.duration; totalDuration = eventData.progress.duration;