{"record":{"id":"a153e7c347f07ccb","repo":"BabylonJS/Babylon.js","slug":"zlib-adler32-mismatch","errorCode":null,"errorMessage":"zlib: adler32 mismatch","messagePattern":"zlib: adler32 mismatch","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/FBX/parsers/zlibInflate.ts","lineNumber":65,"sourceCode":"                break;\r\n            case 2: {\r\n                const { literalLengthTree, distanceTree } = readDynamicTrees(reader);\r\n                inflateCompressedBlock(reader, output, literalLengthTree, distanceTree);\r\n                break;\r\n            }\r\n            default:\r\n                throw new Error(\"deflate: invalid block type\");\r\n        }\r\n    }\r\n\r\n    if (reader.byteOffset < input.byteLength - 4) {\r\n        throw new Error(\"zlib: trailing deflate data\");\r\n    }\r\n\r\n    output.finish();\r\n    const expectedAdler = ((input[input.byteLength - 4] << 24) | (input[input.byteLength - 3] << 16) | (input[input.byteLength - 2] << 8) | input[input.byteLength - 1]) >>> 0;\r\n    if (output.adler32() !== expectedAdler) {\r\n        throw new Error(\"zlib: adler32 mismatch\");\r\n    }\r\n\r\n    return output.bytes;\r\n}\r\n\r\nclass BitReader {\r\n    private bitBuffer = 0;\r\n    private bitCount = 0;\r\n\r\n    public constructor(\r\n        private readonly input: Uint8Array,\r\n        public byteOffset: number,\r\n        private readonly endOffset: number\r\n    ) {}\r\n\r\n    public readBits(count: number): number {\r\n        this.ensureBits(count);\r\n        const value = this.bitBuffer & ((1 << count) - 1);\r","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/FBX/parsers/zlibInflate.ts#L47-L83","documentation":"zlib streams end with an Adler-32 checksum of the uncompressed data. inflateZlib computes the checksum of what it inflated and compares it to the trailer; a mismatch throws 'zlib: adler32 mismatch', meaning the data decompressed without error but is not the data that was compressed — silent corruption.","triggerScenarios":"Any bit corruption inside the compressed payload that the deflate decoder tolerated, wrong expectedAdler byte order or trailer offset (e.g., trailing bytes present), or the output buffer's expected length differing from the original stream length.","commonSituations":"Damaged files (network/storage corruption) that still inflate cleanly; payload extracted from a container with stale/incorrect trailer bytes; custom pipelines that recompress data but copy an old checksum.","solutions":["Re-download or re-export the FBX file and verify its hash","Confirm the trailer used is the last 4 bytes of the same compressed buffer (no extra/missing bytes)","If you control generation, recompress the payload so the Adler-32 matches","Treat repeated mismatches across files as a transfer-layer problem (e.g., FTP ASCII mode) and switch to binary-safe transfer"],"exampleFix":"// before\nconst data = fs.readFileSync(p).slice(off, off + len); // trailer from stale slice\n// after\nconst end = off + declaredCompressedLength; const data = fs.readFileSync(p).slice(off, end); // trailer = last 4 bytes of this buffer","handlingStrategy":"try-catch","validationCode":"// verify whole-file integrity before parse so corruption is caught early\nif (sha256(await fs.readFile(path)) !== manifestHash) {\n  throw new Error('FBX file failed integrity check');\n}","typeGuard":null,"tryCatchPattern":"try {\n  return inflateZlib(compressed, expectedLength);\n} catch (e) {\n  if ((e as Error).message === 'zlib: adler32 mismatch') {\n    throw new Error('FBX compressed array failed checksum — file is corrupted in transfer or storage', { cause: e });\n  }\n  throw e;\n}","preventionTips":["Use binary-safe transfers (no FTP ASCII mode) for .fbx assets","Record and verify asset checksums in your pipeline manifest","Re-export rather than hand-editing compressed FBX payloads"],"tags":["zlib","checksum","corrupt-data","fbx"],"backgroundTag":"checksum-mismatch","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}