{"record":{"id":"45fabd46e8babb1c","repo":"BabylonJS/Babylon.js","slug":"status-error-msg","errorCode":null,"errorMessage":"status.error_msg()","messagePattern":"status\\.error_msg\\(\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Meshes/Compression/dracoCompressionWorker.ts","lineNumber":205,"sourceCode":"    const decoderModule = module as DecoderModule;\r\n    let decoder: Nullable<Decoder> = null;\r\n    let buffer: Nullable<DecoderBuffer> = null;\r\n    let geometry: Nullable<Mesh | PointCloud> = null;\r\n\r\n    try {\r\n        decoder = new decoderModule.Decoder();\r\n\r\n        buffer = new decoderModule.DecoderBuffer();\r\n        buffer.Init(data, data.byteLength);\r\n\r\n        let status: Status;\r\n        const type = decoder.GetEncodedGeometryType(buffer);\r\n        switch (type) {\r\n            case decoderModule.TRIANGULAR_MESH: {\r\n                const mesh = new decoderModule.Mesh();\r\n                status = decoder.DecodeBufferToMesh(buffer, mesh);\r\n                if (!status.ok() || mesh.ptr === 0) {\r\n                    throw new Error(status.error_msg());\r\n                }\r\n\r\n                const numFaces = mesh.num_faces();\r\n                const numIndices = numFaces * 3;\r\n                const byteLength = numIndices * 4;\r\n\r\n                const ptr = decoderModule._malloc(byteLength);\r\n                try {\r\n                    decoder.GetTrianglesUInt32Array(mesh, byteLength, ptr);\r\n                    const indices = new Uint32Array(numIndices);\r\n                    indices.set(new Uint32Array(decoderModule.HEAPF32.buffer, ptr, numIndices));\r\n                    onIndicesData(indices);\r\n                } finally {\r\n                    decoderModule._free(ptr);\r\n                }\r\n\r\n                geometry = mesh;\r\n                break;\r","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Meshes/Compression/dracoCompressionWorker.ts#L187-L223","documentation":"DecodeMesh calls the native Draco decoder's DecodeBufferToMesh on a TRIANGULAR_MESH geometry and throws an Error whose message is the native status string when the status is not ok or the returned mesh pointer is null. The actual text comes straight from the Draco decoder (status.error_msg()), so it varies per failure.","triggerScenarios":"Passing a buffer that is not valid Draco TRIANGULAR_MESH data, truncated/corrupted Draco data, data encoded with an incompatible Draco version, or data that is a point cloud being decoded as a mesh.","commonSituations":"Serving .draco/glTF files with wrong Content-Type causing corruption; incomplete downloads; Draco WASM/JS decoder version mismatch with encoder version; attempting to decode an arbitrary binary file as Draco.","solutions":["Verify the input buffer is complete, uncorrupted Draco-compressed mesh data (check file size/checksum).","Match the Draco decoder module version to the version used for encoding.","Confirm the data is a triangular mesh, not a point cloud (POINT_CLOUD takes a different branch).","Catch this in the worker host and surface status.error_msg() alongside the byte range/source of the buffer to diagnose."],"exampleFix":"// before\nawait DracoCompression.DecodeMeshToGeometryAsync(name, scene, bufferOfUnknownOrigin);\n\n// after\nif (!isDracoBuffer(buffer) || buffer.byteLength === 0) {\n  throw new Error('Refusing to decode: buffer is not valid Draco data');\n}\nawait DracoCompression.DecodeMeshToGeometryAsync(name, scene, buffer);","handlingStrategy":"validation","validationCode":"if (!(data instanceof ArrayBuffer) || data.byteLength < 20) {\n  throw new Error('invalid Draco mesh payload: too small or wrong type');\n}","typeGuard":"const isNonEmptyBuffer = (d: unknown): d is ArrayBuffer =>\n  d instanceof ArrayBuffer && d.byteLength > 0;","tryCatchPattern":"try {\n  geometry = await DracoCompression.DecodeMeshToGeometryAsync(name, scene, buffer);\n} catch (e) {\n  console.error('Draco mesh decode failed:', e?.message); // includes native status.error_msg()\n  geometry = null; // fall back to uncompressed asset\n}","preventionTips":["Verify asset integrity (size/checksum) before decoding; handle partial downloads.","Keep the draco_decoder module version aligned with the encoder version.","Confirm mesh vs point-cloud payloads are routed to the right decode path.","Always keep an uncompressed fallback asset or re-fetch path."],"tags":["draco","decoding","wasm","data-corruption"],"backgroundTag":"decode-failed","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}