fix: video size error handling — validation, timeouts, failure surfacing
Backend: - Increase ffmpeg/ffprobe timeouts from 15s to 60s for large videos - Classify processing errors (timeout, OOM, corrupt) with user-facing messages - Emit failure details via media:job:update socket event (error field) - Bump refboard container memory 512M → 1G Frontend: - Client-side file size validation (200MB) before upload starts - Oversized files show immediate error in upload manager, skip upload - Handle media:job:update status='failed' — surface error in upload panel - Add processingFailed() to UploadManager for video processing errors
This commit is contained in:
@@ -7,6 +7,10 @@ import { uploadImage, uploadImageFromUrl } from '../api';
|
||||
|
||||
type OnChange = () => void;
|
||||
|
||||
/** Client-side file size limit (matches backend MAX_FILE_SIZE_MB default) */
|
||||
const MAX_FILE_SIZE_MB = 200;
|
||||
const MAX_FILE_SIZE = MAX_FILE_SIZE_MB * 1024 * 1024;
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Placeholder helper */
|
||||
/* ------------------------------------------------------------------ */
|
||||
@@ -153,6 +157,15 @@ export function setupDragDrop(
|
||||
let cursorX = world.x;
|
||||
for (let c = 0; c < col; c++) cursorX += (colWidths[c] || 220) + GAP;
|
||||
|
||||
// Client-side size validation
|
||||
if (file.size > MAX_FILE_SIZE) {
|
||||
const jobId = uploads?.addJob(file, boardId);
|
||||
if (jobId) uploads?.setFailed(jobId, `File too large (${(file.size / 1024 / 1024).toFixed(0)}MB, max ${MAX_FILE_SIZE_MB}MB)`);
|
||||
col++;
|
||||
if (col >= cols) { col = 0; row++; cursorY += rowMaxH + GAP; rowMaxH = 0; }
|
||||
continue;
|
||||
}
|
||||
|
||||
const placeholder = createPlaceholder(viewport, cursorX, cursorY);
|
||||
const jobId = uploads?.addJob(file, boardId);
|
||||
|
||||
@@ -241,6 +254,13 @@ export function setupPaste(
|
||||
const file = item.getAsFile();
|
||||
if (!file) continue;
|
||||
|
||||
// Client-side size validation
|
||||
if (file.size > MAX_FILE_SIZE) {
|
||||
const jobId = uploads?.addJob(file, boardId);
|
||||
if (jobId) uploads?.setFailed(jobId, `File too large (${(file.size / 1024 / 1024).toFixed(0)}MB, max ${MAX_FILE_SIZE_MB}MB)`);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Place at viewport center (world coords)
|
||||
const center = viewport.center;
|
||||
const cx = center.x;
|
||||
|
||||
@@ -184,10 +184,18 @@ export function useCanvasSetup(deps: CanvasSetupDeps) {
|
||||
|
||||
// Media processing pipeline: upgrade videos when poster/metadata arrives
|
||||
socket.on('media:job:update', (data: any) => {
|
||||
if (!data || data.status !== 'done') return;
|
||||
const { imageId, posterAssetKey, nativeWidth, nativeHeight, duration } = data;
|
||||
if (!data) return;
|
||||
const { imageId, status } = data;
|
||||
if (!imageId) return;
|
||||
|
||||
// Surface processing failures to upload manager
|
||||
if (status === 'failed') {
|
||||
uploadManager.processingFailed(imageId, data.error || 'Video processing failed');
|
||||
return;
|
||||
}
|
||||
if (status !== 'done') return;
|
||||
const { posterAssetKey, nativeWidth, nativeHeight, duration } = data;
|
||||
|
||||
// Update upload manager — transitions video jobs from "processing" to "done"
|
||||
uploadManager.processingComplete(imageId);
|
||||
|
||||
|
||||
@@ -88,6 +88,18 @@ export class UploadManager {
|
||||
}
|
||||
}
|
||||
|
||||
/** Video processing failed (from media:job:update socket event with status='failed'). */
|
||||
processingFailed(imageId: string, error: string) {
|
||||
for (const job of this.jobs.values()) {
|
||||
if (job.imageId === imageId && (job.status === 'processing' || job.status === 'uploading')) {
|
||||
job.status = 'failed';
|
||||
job.error = error;
|
||||
this._notify();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Mark a job as failed. */
|
||||
setFailed(jobId: string, error: string) {
|
||||
const job = this.jobs.get(jobId);
|
||||
|
||||
Reference in New Issue
Block a user