oven-sh/bun · error · Error
First buffer was modified
Error message
First buffer was modified
What it means
The package list byte range [begin_at, end_at] read from the lockfile header falls outside the declared buffer end or is inverted (begin > end) (src/install/lockfile/Package.rs:3218-3221, re-checked later at 3401-3407).
Source
Thrown at bench/snippets/buffer-concat.mjs:35
? 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");
const array = Array.from({ length: 100 }, () => chunk);
bench("Buffer.concat 100 tiny chunks", () => {
return Buffer.concat(array);
});
View on GitHub (pinned to 8c5296ac45)
Solutions
- Restore bun.lockb from version control
- Otherwise delete it and run `bun install` to rebuild
- Avoid killing installs mid-save and keep bun.lockb out of filters/merges
Defensive patterns
Strategy: fallback
Prevention
- Do not interrupt installs during the lockfile save phase
- Restore bun.lockb from git on corruption; regenerate as a last resort
- Keep binary lockfiles away from filters, merges, and manual edits
When it happens
Trigger: Corrupted offset fields in bun.lockb - partial writes, bit rot, or a file assembled from mismatched pieces.
Common situations: Same corruption class as the other validation failures: interrupted saves, binary merge conflicts, transfer mangling.
Related errors
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/d0651b4b15a06410.
Report an issue: GitHub.