fix: early PDF validation, type-aware errors, exact job dedup
- Move PDF page count check before MinIO upload and DB record creation to prevent orphaned objects when >500 page PDFs are rejected - Use job type label (PDF page / Video) in media-worker error messages instead of hardcoded "Video processing failed" - Replace LIKE-based idempotency check with exact JSON match to prevent page 1 matching page 11/12/etc substring collisions
This commit is contained in:
@@ -144,13 +144,14 @@ async function processJob(job) {
|
||||
console.error('[media-worker] Job %s failed:', jobId, err.message);
|
||||
|
||||
// Classify error for user-facing message
|
||||
let userError = 'Video processing failed';
|
||||
const typeLabel = job.type.startsWith('pdf-') ? 'PDF page' : 'Video';
|
||||
let userError = `${typeLabel} processing failed`;
|
||||
if (err.killed || err.signal === 'SIGTERM') {
|
||||
userError = 'Video processing timed out — file may be too large or corrupt';
|
||||
userError = `${typeLabel} processing timed out — file may be too large or corrupt`;
|
||||
} else if (err.message?.includes('ENOMEM') || err.message?.includes('Cannot allocate')) {
|
||||
userError = 'Out of memory — video file is too large to process';
|
||||
userError = `Out of memory — file is too large to process`;
|
||||
} else if (err.message?.includes('Invalid data')) {
|
||||
userError = 'Invalid or corrupt video file';
|
||||
userError = `Invalid or corrupt ${typeLabel.toLowerCase()} file`;
|
||||
}
|
||||
|
||||
const attempts = (job.attempts || 0) + 1;
|
||||
|
||||
Reference in New Issue
Block a user