oven-sh/bun · error · Error

Wrong third byte

Error message

Wrong third byte

What it means

The package MultiArrayList field count is neither FIELD_COUNT nor FIELD_COUNT - 1 (the latter is the pre-0.6.8 layout without the 'scripts' field, which Bun back-fills from package.json) (src/install/lockfile/Package.rs:3207-3215).

Source

Thrown at bench/snippets/buffer-concat.mjs:32

  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");
const array = Array.from({ length: 100 }, () => chunk);
bench("Buffer.concat 100 tiny chunks", () => {

View on GitHub (pinned to 8c5296ac45)

Solutions

  1. Upgrade Bun so reader and writer share the schema, then reinstall
  2. Or delete bun.lockb and regenerate it with the current Bun
  3. Align the team on one Bun version to stop the file flip-flopping
Defensive patterns

Strategy: fallback

Prevention

When it happens

Trigger: A bun.lockb written by a serializer with a different package schema, or field-count bytes altered by corruption.

Common situations: Incompatible Bun versions writing/reading the same lockfile; binary merge damage.

Related errors


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/dfa733e97efbc428. Report an issue: GitHub.