usebruno/bruno · error · TypeError

getRandomValues: Invalid or unsupported typed array type: ${

Error message

getRandomValues: Invalid or unsupported typed array type: ${obj.type}

What it means

Thrown by deserializeTypedArray when the serialized object's `type` field is missing, not a string, or not one of the allowed typed-array constructor names (Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, BigInt64Array, BigUint64Array). The check is an allowlist — anything outside the set is rejected.

Source

Thrown at packages/bruno-js/src/sandbox/quickjs/shims/lib/utils.js:30

    'Int8Array',
    'Uint8Array',
    'Uint8ClampedArray',
    'Int16Array',
    'Uint16Array',
    'Int32Array',
    'Uint32Array',
    'Float32Array',
    'Float64Array',
    'BigInt64Array',
    'BigUint64Array'
  ]);

  if (!obj || typeof obj !== 'object') {
    throw new TypeError('getRandomValues: Invalid typed array object');
  }

  if (typeof obj.type !== 'string' || !allowedConstructors.has(obj.type)) {
    throw new TypeError(`getRandomValues: Invalid or unsupported typed array type: ${obj.type}`);
  }

  if (!obj.array || typeof obj.length !== 'number') {
    throw new TypeError('getRandomValues: Invalid typed array properties');
  }

  const ctor = globalThis[obj.type];
  if (typeof ctor !== 'function') {
    throw new TypeError(`getRandomValues: Constructor ${obj.type} is not available`);
  }

  return new ctor(obj.array, 0, obj.length);
}

module.exports = {
  serializeTypedArray,
  deserializeTypedArray
};

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Use one of the supported typed arrays directly: `new Uint8Array(n)`.
  2. Avoid hand-building the serialized object — let serializeTypedArray produce it.
  3. If using a subclass, pass the underlying base typed array instead.

Example fix

// before — DataView is not in the allowlist
crypto.getRandomValues(new DataView(buf));

// after
crypto.getRandomValues(new Uint8Array(buf));
Defensive patterns

Strategy: type-guard

Validate before calling

const ALLOWED = new Set(['Int8Array','Uint8Array','Uint8ClampedArray','Int16Array','Uint16Array','Int32Array','Uint32Array','Float32Array','Float64Array','BigInt64Array','BigUint64Array']);
function assertType(name) { if (!ALLOWED.has(name)) throw new TypeError('bad type ' + name); }

Type guard

const isAllowedType = (v) => typeof v === 'string' && ALLOWED.has(v);

Try / catch

try { crypto.getRandomValues(arr); }
catch (err) {
  if (/Invalid or unsupported typed array type/.test(err.message)) {
    crypto.getRandomValues(new Uint8Array(arr));
  } else throw err;
}

Prevention

When it happens

Trigger: A custom object hand-rolled to look like the serialized shape but with a wrong/missing `type`; an attempt to pass a DataView or a non-typed array; corruption of the serialized payload across the QuickJS marshalling boundary.

Common situations: Trying crypto.getRandomValues with a DataView (not supported); passing a plain Array; the constructor name on the host side differs (e.g. a polyfilled Uint8Array subclass).

Related errors


AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13). Data as JSON: /api/errors/51abbb202caaafb1. Report an issue: GitHub.