slymnoyann/hey-1 · error · Error
Video file is empty
Error message
Video file is empty
What it means
Thrown by generateVideoThumbnails when the provided File object has a size of 0. The helper uses the browser's video/canvas APIs to seek through the video and capture frames, and an empty file cannot be loaded or decoded. This is an upfront sanity check before any DOM video work begins.
Source
Thrown at src/helpers/generateVideoThumbnails.ts:6
const generateVideoThumbnails = async (
file: File,
count: number
): Promise<string[]> => {
if (!file.size) {
throw new Error("Video file is empty");
}
const url = URL.createObjectURL(file);
const video = document.createElement("video");
const canvas = document.createElement("canvas");
video.muted = true;
video.src = url;
try {
await new Promise<void>((resolve, reject) => {
video.onloadeddata = () => {
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
resolve();
};
video.onerror = () => reject(new Error("Failed to load video"));
});
View on GitHub (pinned to 88c8f9d553)
Solutions
- Check file.size > 0 in the file-picker change handler before calling generateVideoThumbnails
- Verify the source of the File (input, drop, blob slice) actually contains data by logging file.size and file.type
- If the file comes from a download/stream, wait until it is fully written before processing
- Show a user-facing validation message asking them to re-select the video
Example fix
// before
const thumbs = await generateVideoThumbnails(file, 4);
// after
if (file.size === 0) {
throw new Error("Please select a non-empty video file");
}
const thumbs = await generateVideoThumbnails(file, 4); Defensive patterns
Strategy: validation
Validate before calling
if (!(file instanceof File) || file.size === 0) {
throw new Error("Video file is empty");
}
const isVideo = file.type.startsWith("video/");
if (!isVideo) {
throw new Error("Not a video file");
} Type guard
const isNonEmptyFile = (f: unknown): f is File => f instanceof File && f.size > 0;
Try / catch
try {
const thumbs = await generateVideoThumbnails(file, count);
} catch (e) {
if (e instanceof Error && e.message === "Video file is empty") {
// prompt user to re-select the file
}
throw e;
} Prevention
- Validate file.size > 0 in the file input change handler
- Reject 0-byte files at drag-drop time with a visible message
- Avoid constructing File objects from unverified blob slices
When it happens
Trigger: Passing a File obtained from an <input type="file"> or drag-drop where the file handle exists but the content is 0 bytes; a blob slice that produced an empty File; or a file that failed mid-read before being handed to the helper.
Common situations: User selects a video that is still syncing/downloading (0 bytes on disk), a canceled or interrupted upload/drag operation, constructing a File from an empty Blob, or a test fixture created with new File([], 'video.mp4').
Related errors
AI-assisted analysis of slymnoyann/hey-1@88c8f9d553 (2026-08-28).
Data as JSON: /api/errors/0449c1b1badd2db2.
Report an issue: GitHub.