{"record":{"id":"1714f20e83421f1e","repo":"BabylonJS/Babylon.js","slug":"context-e-message","errorCode":null,"errorMessage":"${context}: ${e.message}","messagePattern":"\\$\\{context\\}: \\$\\{e\\.message\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts","lineNumber":2066,"sourceCode":"        }\r\n\r\n        if (!buffer._data) {\r\n            if (buffer.uri) {\r\n                buffer._data = this.loadUriAsync(`${context}/uri`, buffer, buffer.uri);\r\n            } else {\r\n                if (!this._bin) {\r\n                    throw new Error(`${context}: Uri is missing or the binary glTF is missing its binary chunk`);\r\n                }\r\n\r\n                buffer._data = this._bin.readAsync(0, buffer.byteLength);\r\n            }\r\n        }\r\n\r\n        return buffer._data.then((data) => {\r\n            try {\r\n                return new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);\r\n            } catch (e) {\r\n                throw new Error(`${context}: ${e.message}`, { cause: e });\r\n            }\r\n        });\r\n    }\r\n\r\n    /**\r\n     * Loads a glTF buffer view.\r\n     * @param context The context when loading the asset\r\n     * @param bufferView The glTF buffer view property\r\n     * @returns A promise that resolves with the loaded data when the load is complete\r\n     */\r\n    public loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView> {\r\n        const extensionPromise = this._extensionsLoadBufferViewAsync(context, bufferView);\r\n        if (extensionPromise) {\r\n            return extensionPromise;\r\n        }\r\n\r\n        if (bufferView._data) {\r\n            return bufferView._data;\r","sourceCodeStart":2048,"sourceCodeEnd":2084,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts#L2048-L2084","documentation":"After a glTF buffer's data promise resolves, the loader slices a Uint8Array view at (byteOffset, byteLength). If that slicing throws (typically a RangeError because byteOffset+byteLength exceeds the buffer data), the underlying exception is re-thrown wrapped with the buffer's context path. This is a bounds-check failure on the resolved binary data.","triggerScenarios":"A bufferView/accessor whose byteOffset/byteLength lies outside the actual buffer data — e.g. the .bin file is truncated, a wrong byteLength is declared, or the wrong .bin was paired with the .gltf.","commonSituations":"Mismatched .gltf/.bin pairs after manual file management, partially uploaded/truncated binary chunks, files edited by scripts that change byteLength without regenerating data, GLB chunks cut short by a bad download.","solutions":["Re-download or re-export the asset so the binary data matches the declared byteLength.","Ensure the .bin file paired with the .gltf is the correct, complete one.","Check buffer/byteLength values in the JSON against the actual binary size.","Validate with glTF-Validator, which reports out-of-range buffer references."],"exampleFix":"// before: buffer.byteLength = 4096 but scene.bin is only 2048 bytes\n// after: re-export so scene.bin is 4096 bytes, or fix the JSON\n\"buffers\": [{ \"uri\": \"scene.bin\", \"byteLength\": 2048 }]","handlingStrategy":"validation","validationCode":"const binSize = binBuffer.byteLength;\nfor (const bv of gltf.bufferViews ?? []) {\n  const buf = gltf.buffers?.[bv.buffer];\n  if (buf && (bv.byteOffset ?? 0) + (bv.byteLength ?? 0) > binSize) {\n    throw new Error(`bufferView out of range: needs ${bv.byteLength} bytes at ${bv.byteOffset}, bin has ${binSize}`);\n  }\n}","typeGuard":"function viewFitsInBuffer(bv: { byteOffset?: number; byteLength?: number }, binSize: number): boolean {\n  return (bv.byteOffset ?? 0) + (bv.byteLength ?? 0) <= binSize;\n}","tryCatchPattern":"try { await loadAsset(); } catch (e) {\n  if (e instanceof Error && /RangeError|buffer out of bounds|byteLength/.test(e.message)) {\n    // re-fetch the binary data; it is likely truncated\n  }\n}","preventionTips":["Verify binary file sizes against declared byteLength at ingestion.","Check download integrity (Content-Length / checksums) for .bin and .glb files.","Never pair a .gltf with a .bin from a different export."],"tags":["gltf","buffer","range-error","binary-data","asset-loading"],"backgroundTag":"buffer-out-of-bounds","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}