chore(auto): task completed - unknown

This commit is contained in:
MythEclipse
2026-06-13 13:35:11 +07:00
parent d569ffa2db
commit 2e14b5e4ed
22 changed files with 516 additions and 172 deletions
@@ -213,8 +213,9 @@ export function resolveMediaUrl(
}
});
// -- stderr (capture for diagnostics) ----------------------------------
// -- stderr (capture for diagnostics, capped at 4KB) ----------------------------------
const MAX_STDERR = 4096;
if (proc.stderr) {
proc.stderr.on("data", (chunk: Buffer) => {
stderrBuf += chunk.toString("utf8");
@@ -295,6 +296,7 @@ export async function extractMediaInfo(url: string): Promise<MediaInfo> {
let stdoutBuf = "";
let stderrBuf = "";
const MAX_STDERR = 4096;
if (proc.stdout) {
proc.stdout.on("data", (chunk: Buffer) => {
@@ -304,7 +306,9 @@ export async function extractMediaInfo(url: string): Promise<MediaInfo> {
if (proc.stderr) {
proc.stderr.on("data", (chunk: Buffer) => {
stderrBuf += chunk.toString("utf8");
if (stderrBuf.length < MAX_STDERR) {
stderrBuf += chunk.toString("utf8").slice(0, MAX_STDERR - stderrBuf.length);
}
});
}
@@ -1,9 +1,10 @@
import { createChildLogger } from "@bete/shared/logger";
import { eq } from "drizzle-orm";
import type { NodePgDatabase } from "drizzle-orm/node-postgres";
import { getDatabase } from "../../shared/database/drizzle.js";
import { muxerJobsTable } from "../../shared/database/schema.js";
import { config } from "../../shared/config/config.js";
import { getDatabase } from "../../shared/database/drizzle.js";
import type * as schema from "../../shared/database/schema.js";
import { muxerJobsTable } from "../../shared/database/schema.js";
import { buildMuxFfmpegArgs, runFfmpeg } from "./ffmpegProcess.js";
const logger = createChildLogger("muxer");
@@ -59,10 +60,7 @@ export function startMuxerWorker(): void {
pollTimer = setInterval(() => {
processNextJobs().catch((err: unknown) => {
logger.error(
{ error: String(err) },
"Muxer worker tick failed",
);
logger.error({ error: String(err) }, "Muxer worker tick failed");
});
}, 10_000);
}
@@ -126,7 +124,9 @@ async function processJob(
const data = JSON.parse(job.data) as MuxerJobData;
if (!data.inputs || data.inputs.length < 2) {
throw new Error(`Muxer job ${job.id} needs at least 2 inputs, got ${data.inputs?.length ?? 0}`);
throw new Error(
`Muxer job ${job.id} needs at least 2 inputs, got ${data.inputs?.length ?? 0}`,
);
}
logger.info(
@@ -156,10 +156,7 @@ async function processJob(
.set({ status: "completed", updatedAt: Date.now() })
.where(eq(muxerJobsTable.id, job.id));
logger.info(
{ jobId: job.id, output: data.output },
"Muxer job completed",
);
logger.info({ jobId: job.id, output: data.output }, "Muxer job completed");
} catch (error) {
const errMsg = error instanceof Error ? error.message : String(error);
const newAttempts = job.attempts + 1;
@@ -174,7 +171,10 @@ async function processJob(
updatedAt: Date.now(),
})
.where(eq(muxerJobsTable.id, job.id));
logger.error({ jobId: job.id, error: errMsg }, "Muxer job failed permanently");
logger.error(
{ jobId: job.id, error: errMsg },
"Muxer job failed permanently",
);
} else {
await db
.update(muxerJobsTable)