heygen-com/hyperframes · error · Error
[build-zip] ${label} at ${path} is too short — read ${bytesR
Error message
[build-zip] ${label} at ${path} is too short — read ${bytesRead} of ${byteCount} bytes. What it means
readFileHead opens a binary file and tries to read byteCount bytes (the ELF header size) from offset 0. If the file is smaller than the header — fewer bytes read than requested — it throws. This catches truncated or corrupt binaries before they reach the ELF validation and produce a confusing error.
Source
Thrown at packages/aws-lambda/scripts/build-zip.ts:385
const magicHex = head.subarray(0, 4).toString("hex");
throw new Error(
`[build-zip] ${label} at ${path} is not a Linux x86-64 ELF executable ` +
`(magic=0x${magicHex}, ei_class=${head[4]}, e_machine=0x${machine.toString(16)}). ` +
`This usually means the deploy host's postinstall fetched a host-platform binary ` +
`(e.g. macOS arm64 ffmpeg) instead of the linux/x64 binary Lambda needs. ` +
`Re-run the build inside a linux/amd64 container, or pre-install with ` +
`\`npm_config_platform=linux npm_config_arch=x64\` so the package fetches the right binary.`,
);
}
function readFileHead(path: string, byteCount: number, label: string): Buffer {
const fd = openSync(path, "r");
try {
const buf = Buffer.alloc(byteCount);
const bytesRead = readSync(fd, buf, 0, byteCount, 0);
if (bytesRead < byteCount) {
throw new Error(
`[build-zip] ${label} at ${path} is too short — read ${bytesRead} of ${byteCount} bytes.`,
);
}
return buf;
} finally {
closeSync(fd);
}
}
function stageFfmpeg(stagingDir: string): void {
const binDir = join(stagingDir, "bin");
mkdirSync(binDir, { recursive: true });
// ffmpeg from `ffmpeg-static`. The package only ships the encoder
// binary; the audio pad/trim path also needs ffprobe, which comes
// from `ffprobe-static`.
//
// `ffmpeg-static`'s postinstall fetches a binary for the host platformView on GitHub (pinned to c2996c8626)
Solutions
- Delete the module from node_modules and reinstall: rm -rf node_modules/ffmpeg-static && bun install.
- Clear the npm cache: npm cache clean --force.
- Verify the binary file size matches expectations (should be tens of MiB, not a few bytes).
Defensive patterns
Strategy: validation
Validate before calling
import { statSync } from "node:fs";
function isHealthyBinary(path: string, minBytes = 1024): boolean {
try {
return statSync(path).size >= minBytes;
} catch {
return false;
}
}
if (!isHealthyBinary(ffmpegBinary)) {
console.error(`${ffmpegBinary} is missing or too small. Reinstall the package.`);
process.exit(1);
} Prevention
- Verify binary file sizes after install in CI.
- Clear npm cache if downloads seem corrupt.
- Use checksums where the package provides them to validate downloads.
When it happens
Trigger: A binary file (ffmpeg, ffprobe, or chrome-headless-shell) exists on disk but is smaller than the ELF header size (~64 bytes) — a truncated download, a corrupt file, or an empty placeholder.
Common situations: An interrupted postinstall download left a partial file; npm cache served a corrupt artifact; a .gitignored placeholder or empty file at the expected path.
Related errors
- Build completed but whisper-cli not found
- --source must be 'sparticuz' or 'chrome-headless-shell' (got
- Unknown flag: ${arg}
- [build-zip] unzipped bundle ${formatBytes(unzippedBytes)} ex
- [build-zip] zip ${formatBytes(zippedBytes)} exceeds ZIP size
AI-assisted analysis of heygen-com/hyperframes@c2996c8626 (2026-08-12).
Data as JSON: /api/errors/fc9e2135385e9fee.
Report an issue: GitHub.