{"record":{"id":"78d854a744be63b2","repo":"denoland/deno","slug":"prefix-writablestream-does-not-support-type","errorCode":null,"errorMessage":"${prefix}: WritableStream does not support 'type' in the underlying sink","messagePattern":"(.+?): WritableStream does not support 'type' in the underlying sink","errorType":"exception","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"ext/web/06_streams.js","lineNumber":7402,"sourceCode":"    }\n    strategy = strategy !== undefined\n      ? webidl.converters.QueuingStrategy(\n        strategy,\n        prefix,\n        \"Argument 2\",\n      )\n      : {};\n    this[_brand] = _brand;\n    if (underlyingSink === undefined) {\n      underlyingSink = null;\n    }\n    const underlyingSinkDict = webidl.converters.UnderlyingSink(\n      underlyingSink,\n      prefix,\n      \"underlyingSink\",\n    );\n    if (underlyingSinkDict.type != null) {\n      throw new RangeError(\n        `${prefix}: WritableStream does not support 'type' in the underlying sink`,\n      );\n    }\n    initializeWritableStream(this);\n    const sizeAlgorithm = extractSizeAlgorithm(strategy);\n    const highWaterMark = extractHighWaterMark(strategy, 1);\n    setUpWritableStreamDefaultControllerFromUnderlyingSink(\n      this,\n      underlyingSink,\n      underlyingSinkDict,\n      highWaterMark,\n      sizeAlgorithm,\n    );\n  }\n\n  /** @returns {boolean} */\n  get locked() {\n    webidl.assertBranded(this, WritableStreamPrototype);","sourceCodeStart":7384,"sourceCodeEnd":7420,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/web/06_streams.js#L7384-L7420","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst ws = new WritableStream({\n  type: 'bytes', // RangeError in Deno\n  write(chunk, ctrl) { file.write(chunk); },\n});\n\n// after\nconst ws = new WritableStream({\n  write(chunk, ctrl) { file.write(chunk); }, // value mode; chunk: Uint8Array\n});","handlingStrategy":"validation","validationCode":"// Only pass `type` when the runtime supports writable byte streams;\n// Deno does not. Strip it before constructing.\nfunction makeWritable(sink) {\n  const { type, ...rest } = sink; // eslint-disable-line no-unused-vars\n  return new WritableStream(rest); // value-mode sink\n}","typeGuard":null,"tryCatchPattern":"try {\n  ws = new WritableStream(sink); // sink may carry type: 'bytes'\n} catch (err) {\n  if (err instanceof RangeError && /does not support 'type'/.test(err.message)) {\n    const { type, ...sink } = rawSink;\n    ws = new WritableStream(sink);\n  } else throw err;\n}","preventionTips":["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."],"tags":["streams","writable-stream","webidl","unsupported-feature"],"backgroundTag":"unsupported-constructor-option","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}