oven-sh/bun · error · Error
Invalid data object: ${JSON.stringify(data)}
Error message
Invalid data object: ${JSON.stringify(data)} What it means
The lockfile's format/version is newer than this Bun understands. For binary bun.lockb: format > FormatVersion::current() (src/install/lockfile/bun.lockb.rs:411-412). During migration it fires for unsupported npm package-lock.json lockfileVersions (src/install/migration.rs:269-278, which suggests regenerating with `npm install --package-lock-only --lockfile-version=3`) and for too-new pnpm lockfile versions (migration.rs:106-115).
Source
Thrown at bench/postMessage/postMessage-object.mjs:60
case ${objects.small.property.length}:
case ${objects.medium.property.length}:
case ${objects.large.property.length}: {
if (
data.a === "a!" &&
data.b === "b!" &&
data.second === "c!" &&
data.bool === true &&
data.nully === null &&
data.undef === undefined &&
data.int === 0 &&
data.double === 1.234 &&
data.falsy === false) {
Atomics.add(int, 0, 1);
break;
}
}
default: {
throw new Error("Invalid data object: " + JSON.stringify(data));
}
}
});
`;
worker = new Worker(workerCode, { eval: true, workerData: receivedCount });
worker.on("message", confirmationId => {});
worker.on("error", error => {
console.error("Worker error:", error);
});
}
// Initialize worker before running benchmarks
createWorker();
View on GitHub (pinned to 8c5296ac45)
Solutions
- Upgrade Bun to at least the version that wrote the lockfile (`bun upgrade` or reinstall)
- For package-lock.json migration, regenerate at v3: `npm install --package-lock-only --lockfile-version=3`
- Or delete the lockfile and let your current Bun re-resolve
- Pin a team-wide Bun version via package.json `packageManager` / engines and CI images
Example fix
# before: older Bun + newer lockfile $ bun install error: Unexpected lockfile version # after $ bun upgrade && bun install
Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from "node:fs";
function lockfileVersionSupported() {
if (existsSync("package-lock.json")) {
const v = require("./package-lock.json").lockfileVersion;
return v === 3; // Bun migrates lockfileVersion 3 only
}
return true; // bun.lock/bun.lockb: upgrade Bun instead
} Type guard
const isSupportedPackageLock = (lock) => typeof lock?.lockfileVersion === "number" && lock.lockfileVersion === 3;
Prevention
- Pin one Bun version across the team via package.json `packageManager` and CI images
- When importing npm projects, regenerate package-lock.json at lockfileVersion 3 before `bun install`
- Watch release notes for lockfile format bumps before upgrading lockfiles in monorepos
When it happens
Trigger: A teammate or CI running a newer Bun committed bun.lockb/bun.lock; migrating a package-lock.json at v1/v2; a pnpm-lock.yaml written by a newer pnpm than Bun's migrator supports.
Common situations: Mixed Bun versions across a team or between local machine and CI; picking up a repo after the lockfile was upgraded elsewhere.
Related errors
- Expected ${receivedCount[0]} to equal ${sentCount}
- size mismatch
- not 200
- picsum ${p.id}: ${res.status}
- Expected ${receivedCount[0]} to equal ${sentCount}
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/d251e48057b20693.
Report an issue: GitHub.