{"record":{"id":"c26d433b14b572c3","repo":"usebruno/bruno","slug":"getrandomvalues-constructor-obj-type-is-not-av","errorCode":null,"errorMessage":"getRandomValues: Constructor ${obj.type} is not available","messagePattern":"getRandomValues: Constructor (.+?) is not available","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/bruno-js/src/sandbox/quickjs/shims/lib/utils.js","lineNumber":39,"sourceCode":"    'BigInt64Array',\n    'BigUint64Array'\n  ]);\n\n  if (!obj || typeof obj !== 'object') {\n    throw new TypeError('getRandomValues: Invalid typed array object');\n  }\n\n  if (typeof obj.type !== 'string' || !allowedConstructors.has(obj.type)) {\n    throw new TypeError(`getRandomValues: Invalid or unsupported typed array type: ${obj.type}`);\n  }\n\n  if (!obj.array || typeof obj.length !== 'number') {\n    throw new TypeError('getRandomValues: Invalid typed array properties');\n  }\n\n  const ctor = globalThis[obj.type];\n  if (typeof ctor !== 'function') {\n    throw new TypeError(`getRandomValues: Constructor ${obj.type} is not available`);\n  }\n\n  return new ctor(obj.array, 0, obj.length);\n}\n\nmodule.exports = {\n  serializeTypedArray,\n  deserializeTypedArray\n};\n","sourceCodeStart":21,"sourceCodeEnd":49,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-js/src/sandbox/quickjs/shims/lib/utils.js#L21-L49","documentation":"Thrown by deserializeTypedArray when `type` is on the allowlist but the matching constructor is not a function on the host's globalThis (e.g. BigInt64Array/BigUint64Array are unavailable in the runtime). This is a defense-in-depth check after the allowlist passes.","triggerScenarios":"Passing a BigInt64Array or BigUint64Array to crypto.getRandomValues in a host runtime that does not expose BigInt typed-array constructors, or any case where globalThis[<allowed name>] is undefined/not-a-function.","commonSituations":"An older Node build with BigInt typed arrays disabled; a restricted runtime where the constructor was deleted or shadowed; sandbox host was started with flags that remove BigInt support.","solutions":["Use a constructor that is definitely present — Uint8Array is the safest choice for random bytes.","Check availability before use: `if (typeof BigInt64Array === 'function') { ... }`.","Upgrade the host runtime if BigInt typed arrays are required."],"exampleFix":"// before\ncrypto.getRandomValues(new BigInt64Array(4)); // constructor missing on host\n\n// after\nconst arr = new Uint8Array(32);\ncrypto.getRandomValues(arr);","handlingStrategy":"type-guard","validationCode":"function ctorAvailable(name) { return typeof globalThis[name] === 'function'; }\nif (!ctorAvailable('BigInt64Array')) throw new TypeError('BigInt typed arrays unavailable');","typeGuard":"const isCtorAvailable = (name) => typeof globalThis[name] === 'function';","tryCatchPattern":"try { crypto.getRandomValues(new BigInt64Array(4)); }\ncatch (err) {\n  if (/is not available/.test(err.message)) {\n    crypto.getRandomValues(new Uint8Array(32));\n  } else throw err;\n}","preventionTips":["Prefer Uint8Array for random bytes to avoid host-availability surprises.","Feature-detect BigInt typed arrays before use."],"tags":["bruno-js","quickjs","sandbox","crypto","webcrypto","runtime","bigint"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}