{"record":{"id":"dfa733e97efbc428","repo":"oven-sh/bun","slug":"wrong-third-byte","errorCode":null,"errorMessage":"Wrong third byte","messagePattern":"Wrong third byte","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"bench/snippets/buffer-concat.mjs","lineNumber":32,"sourceCode":"\n  const fmt =\n    size > 1024 * 1024\n      ? new Intl.NumberFormat(undefined, { unit: \"megabyte\", style: \"unit\" })\n      : size > 1024\n        ? new Intl.NumberFormat(undefined, { unit: \"kilobyte\", style: \"unit\" })\n        : new Intl.NumberFormat(undefined, { unit: \"byte\", style: \"unit\" });\n\n  bench(\n    `Buffer.concat(${fmt.format(\n      Number((size > 1024 * 1024 ? size / 1024 / 1024 : size > 1024 ? size / 1024 : size).toFixed(2)),\n    )} x 3)`,\n    () => {\n      const result = Buffer.concat(buffers);\n      if (check) {\n        if (result.byteLength != size * 3) throw new Error(\"Wrong length\");\n        if (result[0] != 1) throw new Error(\"Wrong first byte\");\n        if (result[size] != 2) throw new Error(\"Wrong second byte\");\n        if (result[size * 2] != 3) throw new Error(\"Wrong third byte\");\n\n        result[0] = 10;\n        if (first[0] != 1) throw new Error(\"First buffer was modified\");\n\n        result[size] = 20;\n        if (second[0] != 2) throw new Error(\"Second buffer was modified\");\n\n        result[size * 2] = 30;\n        if (third[0] != 3) throw new Error(\"Third buffer was modified\");\n      }\n    },\n  );\n}\n\nconst chunk = Buffer.alloc(16);\nchunk.fill(\"3\");\nconst array = Array.from({ length: 100 }, () => chunk);\nbench(\"Buffer.concat 100 tiny chunks\", () => {","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/bench/snippets/buffer-concat.mjs#L14-L50","documentation":"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).","triggerScenarios":"A bun.lockb written by a serializer with a different package schema, or field-count bytes altered by corruption.","commonSituations":"Incompatible Bun versions writing/reading the same lockfile; binary merge damage.","solutions":["Upgrade Bun so reader and writer share the schema, then reinstall","Or delete bun.lockb and regenerate it with the current Bun","Align the team on one Bun version to stop the file flip-flopping"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Align Bun versions across machines so package schema layouts match","Delete and regenerate lockfiles that error with validation failures instead of retrying"],"tags":["lockfile","corruption","version","validation"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}