From 9ae619357b8901dfdfa225ef4679bede4dcefe07 Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Tue, 2 Jun 2026 18:39:08 -0400 Subject: [PATCH] =?UTF-8?q?feat/fix:=20proxy.js=20=E2=80=94=20growing=20mi?= =?UTF-8?q?grate=20flow=20+=20deltacast=20cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/worker/src/workers/proxy.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/services/worker/src/workers/proxy.js b/services/worker/src/workers/proxy.js index c5e51a9..7330302 100644 --- a/services/worker/src/workers/proxy.js +++ b/services/worker/src/workers/proxy.js @@ -78,21 +78,25 @@ export const proxyWorker = async (job) => { const outputPath = join(tmpDir, `proxy-output-${job.id}.mp4`); try { + // Look up the asset row early — check status before doing any work, + // and read media_type for routing decisions below. + const assetRow = await query( + 'SELECT status, media_type FROM assets WHERE id = $1', + [assetId] + ); + const asset = assetRow.rows[0]; + const dbMediaType = asset?.media_type || null; + + if (asset?.status === 'pending_migration') { + console.log(`[proxy] asset ${assetId} is pending_migration, skipping`); + return; + } + // Download original from S3 await job.updateProgress(10); console.log(`[proxy] Downloading ${inputKey} for asset ${assetId}`); await downloadFromS3(S3_BUCKET, inputKey, inputPath); - // Look up the asset row early — we want media_type before deciding how - // to process. That lets us route 'image' assets to the poster path even - // when ffprobe doesn't return a codec name in IMAGE_CODECS (e.g. future - // formats like AVIF / HEIF / JPEG-XL). - const assetRow = await query( - 'SELECT media_type FROM assets WHERE id = $1', - [assetId] - ); - const dbMediaType = assetRow.rows[0]?.media_type || null; - // Reject obviously-empty inputs before handing them to ffmpeg. Aborted // SRT/RTMP recordings end up as 0-byte (or ftyp-only ~1KB) objects in S3 // when the source disconnects before any frame is received; the proxy