denoland/deno · error · RangeError
${prefix}: WritableStream does not support 'type' in the und
Error message
${prefix}: WritableStream does not support 'type' in the underlying sink What it means
RangeError thrown by the WritableStream constructor when the converted underlyingSink dictionary has a non-null `type` member (ext/web/06_streams.js). Deno implements value-mode writable streams only; 'bytes' (writable byte streams) and any other type value are unsupported, so the constructor refuses the sink at creation time.
Source
Thrown at ext/web/06_streams.js:7402
}
strategy = strategy !== undefined
? webidl.converters.QueuingStrategy(
strategy,
prefix,
"Argument 2",
)
: {};
this[_brand] = _brand;
if (underlyingSink === undefined) {
underlyingSink = null;
}
const underlyingSinkDict = webidl.converters.UnderlyingSink(
underlyingSink,
prefix,
"underlyingSink",
);
if (underlyingSinkDict.type != null) {
throw new RangeError(
`${prefix}: WritableStream does not support 'type' in the underlying sink`,
);
}
initializeWritableStream(this);
const sizeAlgorithm = extractSizeAlgorithm(strategy);
const highWaterMark = extractHighWaterMark(strategy, 1);
setUpWritableStreamDefaultControllerFromUnderlyingSink(
this,
underlyingSink,
underlyingSinkDict,
highWaterMark,
sizeAlgorithm,
);
}
/** @returns {boolean} */
get locked() {
webidl.assertBranded(this, WritableStreamPrototype);View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Remove the `type` property from the underlyingSink object; write Uint8Array chunks through a default WritableStream instead.
- If byte-level control is needed, wrap a WritableStream around a File/FsFile or socket sink and accept ArrayBufferView chunks.
- Check feature support before passing type: only include it when the runtime advertises writable byte streams.
Example fix
// before
const ws = new WritableStream({
type: 'bytes', // RangeError in Deno
write(chunk, ctrl) { file.write(chunk); },
});
// after
const ws = new WritableStream({
write(chunk, ctrl) { file.write(chunk); }, // value mode; chunk: Uint8Array
}); Defensive patterns
Strategy: validation
Validate before calling
// Only pass `type` when the runtime supports writable byte streams;
// Deno does not. Strip it before constructing.
function makeWritable(sink) {
const { type, ...rest } = sink; // eslint-disable-line no-unused-vars
return new WritableStream(rest); // value-mode sink
} Try / catch
try {
ws = new WritableStream(sink); // sink may carry type: 'bytes'
} catch (err) {
if (err instanceof RangeError && /does not support 'type'/.test(err.message)) {
const { type, ...sink } = rawSink;
ws = new WritableStream(sink);
} else throw err;
} Prevention
- Never send a `type` member in underlyingSink on Deno.
- When porting browser/spec-draft code, delete type before constructing WritableStream.
- Write Uint8Array chunks; they flow through value-mode sinks unchanged.
When it happens
Trigger: new WritableStream({ type: 'bytes', write(chunk, controller) {...} }); any non-null type such as 'direct'. Commonly triggered by libraries or spec-draft-derived code that request byte-oriented sinks.
Common situations: Porting browser/experimental code that relies on writable byte streams (SPECULATION feature); npm packages probing for capability by constructing a typed sink; copy-paste from WHATWG Streams proposals.
Related errors
- A writable stream is not associated with the writer
- Response body is already used
- ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED
- ERR_NOT_IMPLEMENTED
- Context parameter is unsupported
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/78d854a744be63b2.
Report an issue: GitHub.