sindresorhus/is · error · TypeError
Expected value which is `Blob`, received value of type `${is
Error message
Expected value which is `Blob`, received value of type `${is(value)}`. What it means
Thrown by `assertBlob()` when the value fails `isBlob` (object type check for 'Blob'). It guarantees callers can use Blob APIs (`.arrayBuffer()`, `.stream()`, `.size`) without runtime crashes.
Source
Thrown at source/index.ts:1504
throw new TypeError(message ?? typeErrorMessage('bigint', value));
}
}
export function assertBigInt64Array(value: unknown, message?: string): asserts value is BigInt64Array {
if (!isBigInt64Array(value)) {
throw new TypeError(message ?? typeErrorMessage('BigInt64Array', value));
}
}
export function assertBigUint64Array(value: unknown, message?: string): asserts value is BigUint64Array {
if (!isBigUint64Array(value)) {
throw new TypeError(message ?? typeErrorMessage('BigUint64Array', value));
}
}
export function assertBlob(value: unknown, message?: string): asserts value is Blob {
if (!isBlob(value)) {
throw new TypeError(message ?? typeErrorMessage('Blob', value));
}
}
export function assertBoolean(value: unknown, message?: string): asserts value is boolean {
if (!isBoolean(value)) {
throw new TypeError(message ?? typeErrorMessage('boolean', value));
}
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
export function assertBoundFunction(value: unknown, message?: string): asserts value is Function {
if (!isBoundFunction(value)) {
throw new TypeError(message ?? typeErrorMessage('bound Function', value));
}
}
/**
Note: [Prefer using `Uint8Array` instead of `Buffer`.](https://sindresorhus.com/blog/goodbye-nodejs-buffer)View on GitHub ↗ (pinned to 7821031c66)
Solutions
- Convert binary data to a Blob before asserting: `new Blob([buffer])`.
- On Node, ensure Node ≥ 18 (or import Blob from 'node:buffer') so a real Blob class exists.
- If using a Blob polyfill in tests, ensure the same Blob implementation is used by producer and consumer.
- Check `is(value)` in the message to see what you actually received and fix the upstream producer.
Example fix
// before assert.blob(fileBuffer); // after assert.blob(new Blob([fileBuffer]));
Defensive patterns
Strategy: type-guard
Validate before calling
if (!(value instanceof Blob)) {
value = new Blob([value]); // wrap explicitly if raw data
} Type guard
function isBlob(value: unknown): value is Blob {
return typeof Blob !== 'undefined' && value instanceof Blob;
} Try / catch
try {
assert.blob(value);
} catch (error) {
if (error instanceof TypeError) {
// likely a Buffer, ArrayBuffer, or string — wrap in new Blob([...]) or reject
} else throw error;
} Prevention
- In Node, Blob exists only in Node 18+ (node:buffer) — verify runtime support before relying on it
- File extends Blob, so File passes; Buffer and ArrayBuffer do not — wrap them with new Blob([data])
- Check fetch/form-data payloads at the boundary where they enter your code, not deep inside
When it happens
Trigger: Calling `assert.blob(value)` with a Buffer, ArrayBuffer, Uint8Array, string, File-like plain object, or a stream instead of an actual Blob instance.
Common situations: Node.js < 18 (or older polyfill setups) where global `Blob` didn't exist and code passed Buffers instead; form-upload handlers receiving multipart data as Buffers; cross-library confusion between `File`/`Blob` polyfills (e.g., from `fetch-blob`) whose instances may not match the realm's Blob; JSDOM/test environments lacking Blob.
Related errors
- Expected value which is `ArrayBuffer`, received value of typ
- Expected value which is `BigInt64Array`, received value of t
- Expected value which is `Buffer`, received value of type `${
- Expected value which is `DataView`, received value of type `
- Expected value which is `FormData`, received value of type `
AI-assisted analysis of sindresorhus/is@7821031c66 (2026-07-31).
Data as JSON: /data/errors/147e15b268c36ab1.json.
Report an issue: GitHub ↗.