dotnet/aspnetcore · error · Error
Supplied value is not a typed array or blob.
Error message
Supplied value is not a typed array or blob.
What it means
Thrown by DotNet.createJSStreamReference() when the supplied value is neither a Blob nor has a .buffer property that is an ArrayBuffer. The stream reference path only supports Blob or ArrayBufferView inputs; anything else is rejected before length is computed.
Solutions
- Convert the data to a Blob: createJSStreamReference(new Blob([data])).
- Convert to a Uint8Array: createJSStreamReference(new Uint8Array(data)).
- For raw ArrayBuffer, it is auto-wrapped to Uint8Array by the function — pass it directly.
Example fix
// before const ref = createJSStreamReference(readableStream); // ReadableStream is not Blob/TypedArray // after const blob = await new Response(readableStream).blob(); const ref = createJSStreamReference(blob);
Defensive patterns
Strategy: type-guard
Validate before calling
function isStreamable(v) { return v instanceof Blob || (v != null && v.buffer instanceof ArrayBuffer); }
if (!isStreamable(value)) { value = new Blob([value]); } // normalize
const ref = DotNet.createJSStreamReference(value); Type guard
function isStreamInput(v: unknown): v is Blob | ArrayBufferView { return v instanceof Blob || (v != null && (v as any).buffer instanceof ArrayBuffer); } Try / catch
try { return DotNet.createJSStreamReference(value); } catch (e) { throw new Error('createJSStreamReference requires a Blob, ArrayBuffer, or typed array.', { cause: e }); } Prevention
- Convert ReadableStream or Response bodies to Blob/Uint8Array before passing.
- Do not pass plain objects, strings, or numbers to createJSStreamReference.
- Document the supported input types at every interop boundary.
When it happens
Trigger: Passing a plain object, a string, a number, a ReadableStream, or any value that is not instanceof Blob and whose .buffer is not an ArrayBuffer. E.g., createJSStreamReference({ data: [1,2,3] }).
Common situations: Trying to stream a ReadableStream directly instead of a Blob/typed array; passing fetch Response body objects; misunderstanding the API as a generic stream sender.
Related errors
- Cannot create a JSStreamReference from the value
- Cannot create a JSStreamReference from the value
- Byte array index ' ' does not exist.
- Cannot create a JSObjectReference from the value
- Invalid JS call result type
AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11).
Data as JSON: /api/errors/a162b0a236920ce6.
Report an issue: GitHub.
Appendix: source
Thrown at src/JSInterop/Microsoft.JSInterop.JS/src/src/Microsoft.JSInterop.ts:208
export function createJSStreamReference(streamReference: ArrayBuffer | ArrayBufferView | Blob | any): any {
let length = -1;
// If we're given a raw Array Buffer, we interpret it as a `Uint8Array` as
// ArrayBuffers' aren't directly readable.
if (streamReference instanceof ArrayBuffer) {
streamReference = new Uint8Array(streamReference);
}
if (streamReference instanceof Blob) {
length = streamReference.size;
} else if (streamReference.buffer instanceof ArrayBuffer) {
if (streamReference.byteLength === undefined) {
throw new Error(`Cannot create a JSStreamReference from the value '${streamReference}' as it doesn't have a byteLength.`);
}
length = streamReference.byteLength;
} else {
throw new Error("Supplied value is not a typed array or blob.");
}
const result: any = {
[jsStreamReferenceLengthKey]: length
};
try {
const jsObjectReference = createJSObjectReference(streamReference);
result[jsObjectIdKey] = jsObjectReference[jsObjectIdKey];
} catch (error) {
throw new Error(`Cannot create a JSStreamReference from the value '${streamReference}'.`);
}
return result;
}
/**
* Disposes the given JavaScript object reference.View on GitHub (pinned to 3600ca084e)