oven-sh/bun · error · Error
Wrong first byte
Error message
Wrong first byte
What it means
Validation of the binary lockfile's package section rejected the list length header: it exceeds u32::MAX - 1, an impossible package count (src/install/lockfile/Package.rs:3191-3193). The check exists to refuse absurd allocations before trusting the header.
Source
Thrown at bench/snippets/buffer-concat.mjs:30
const buffers = [first, second, third];
const fmt =
size > 1024 * 1024
? new Intl.NumberFormat(undefined, { unit: "megabyte", style: "unit" })
: size > 1024
? new Intl.NumberFormat(undefined, { unit: "kilobyte", style: "unit" })
: new Intl.NumberFormat(undefined, { unit: "byte", style: "unit" });
bench(
`Buffer.concat(${fmt.format(
Number((size > 1024 * 1024 ? size / 1024 / 1024 : size > 1024 ? size / 1024 : size).toFixed(2)),
)} x 3)`,
() => {
const result = Buffer.concat(buffers);
if (check) {
if (result.byteLength != size * 3) throw new Error("Wrong length");
if (result[0] != 1) throw new Error("Wrong first byte");
if (result[size] != 2) throw new Error("Wrong second byte");
if (result[size * 2] != 3) throw new Error("Wrong third byte");
result[0] = 10;
if (first[0] != 1) throw new Error("First buffer was modified");
result[size] = 20;
if (second[0] != 2) throw new Error("Second buffer was modified");
result[size * 2] = 30;
if (third[0] != 3) throw new Error("Third buffer was modified");
}
},
);
}
const chunk = Buffer.alloc(16);
chunk.fill("3");View on GitHub (pinned to 8c5296ac45)
Solutions
- Restore bun.lockb from git
- Otherwise delete it and run `bun install` to regenerate
Defensive patterns
Strategy: fallback
Prevention
- Never commit a non-lockfile file as bun.lockb
- Restore or regenerate on any corruption-class failure
- Keep bun.lockb out of text-processing pipelines
When it happens
Trigger: A bun.lockb whose length field is random/garbage bytes - e.g. a non-lockfile file at that path, severe corruption, or a file mangled in transfer.
Common situations: Binary merge damage, wrong file committed as bun.lockb, storage corruption.
Related errors
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/2592bbcce16be9cc.
Report an issue: GitHub.