{"record":{"id":"bfa102b848a8442e","repo":"zloirock/core-js","slug":"arraybuffer-expected","errorCode":null,"errorMessage":"ArrayBuffer expected","messagePattern":"ArrayBuffer expected","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core-js/internals/array-buffer-byte-length.js","lineNumber":13,"sourceCode":"'use strict';\nvar globalThis = require('../internals/global-this');\nvar uncurryThisAccessor = require('../internals/function-uncurry-this-accessor');\nvar classof = require('../internals/classof-raw');\n\nvar ArrayBuffer = globalThis.ArrayBuffer;\nvar TypeError = globalThis.TypeError;\n\n// Includes\n// - Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).\n// - If IsSharedArrayBuffer(O) is true, throw a TypeError exception.\nmodule.exports = ArrayBuffer && uncurryThisAccessor(ArrayBuffer.prototype, 'byteLength', 'get') || function (O) {\n  if (classof(O) !== 'ArrayBuffer') throw new TypeError('ArrayBuffer expected');\n  return O.byteLength;\n};\n","sourceCodeStart":1,"sourceCodeEnd":16,"githubUrl":"https://github.com/zloirock/core-js/blob/84e45fba098dd3a177d5cf2247d06ab8e98d3790/packages/core-js/internals/array-buffer-byte-length.js#L1-L16","documentation":"core-js's arrayBufferByteLength helper returns the byteLength of an ArrayBuffer, falling back to a manual implementation when the native getter is unavailable. In the fallback it first verifies the argument's internal class is 'ArrayBuffer'; otherwise it throws 'TypeError: ArrayBuffer expected'. The spec step this mirrors is RequireInternalSlot(O, [[ArrayBufferData]]), so it fires when you pass something that is not an ArrayBuffer (note shared ArrayBuffers are rejected elsewhere).","triggerScenarios":"Calling arrayBufferByteLength(O) with a non-ArrayBuffer value: a DataView, a typed array, a SharedArrayBuffer (in builds where the native getter path is skipped), a plain object, or undefined/null.","commonSituations":"Polyfilled environments (older engines without ArrayBuffer.prototype byteLength accessor) where the fallback path runs; code that confuses a typed array for its .buffer; passing a SharedArrayBuffer by mistake; transitive failure through other core-js polyfills (e.g. ArrayBuffer.prototype.slice, DataView internals) given a wrong argument.","solutions":["Pass an actual ArrayBuffer instance (use typedArray.buffer when starting from a typed array).","Verify the value with Object.prototype.toString.call(v) === '[object ArrayBuffer]' before calling.","If you hold a SharedArrayBuffer, switch to a regular ArrayBuffer — the spec explicitly rejects shared buffers here.","Ensure a consistent core-js version/config; mismatched polyfill setups can route to the fallback path unexpectedly."],"exampleFix":"// before\nvar len = arrayBufferByteLength(typedArray); // TypeError: ArrayBuffer expected\n// after\nvar len = arrayBufferByteLength(typedArray.buffer);","handlingStrategy":"validation","validationCode":"function isArrayBuffer(v){ return Object.prototype.toString.call(v) === '[object ArrayBuffer]'; }\nif (!isArrayBuffer(input)) throw new TypeError('expected an ArrayBuffer');","typeGuard":"function isArrayBuffer(v){ return Object.prototype.toString.call(v) === '[object ArrayBuffer]'; }","tryCatchPattern":"try { len = arrayBufferByteLength(input); } catch (e) { if (e instanceof TypeError) len = fallbackLength(input); else throw e; }","preventionTips":["Always pass .buffer when starting from a typed array.","Remember SharedArrayBuffer is rejected here.","In polyfilled/legacy environments, validate class with Object.prototype.toString before calling.","Pin a single core-js version to keep fallback behavior consistent."],"tags":["typeerror","arraybuffer","polyfill","type-mismatch"],"backgroundTag":"arraybuffer-expected","analyzedSha":"84e45fba098dd3a177d5cf2247d06ab8e98d3790","analyzedAt":"2026-08-30T20:36:10.323Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}