{"record":{"id":"fa559caf1fd8609e","repo":"clockworklabs/SpacetimeDB","slug":"option-stream-not-supported","errorCode":null,"errorMessage":"Option 'stream' not supported","messagePattern":"Option 'stream' not supported","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"crates/core/src/host/v8/builtins/text_encoding.js","lineNumber":57,"sourceCode":"  }\n\n  get encoding() {\n    return this.#encoding;\n  }\n  get fatal() {\n    return this.#fatal;\n  }\n  get ignoreBOM() {\n    return false;\n  }\n\n  /**\n   * @argument {any} input\n   * @argument {any} options\n   */\n  decode(input, options = {}) {\n    if (options.stream) {\n      throw new TypeError(\"Option 'stream' not supported\");\n    }\n    if (input instanceof ArrayBuffer || input instanceof SharedArrayBuffer) {\n      input = new Uint8Array(input);\n    }\n    return utf8_decode(input, this.#fatal);\n  }\n};\n","sourceCodeStart":39,"sourceCodeEnd":65,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/core/src/host/v8/builtins/text_encoding.js#L39-L65","documentation":"The builtin TextDecoder only supports one-shot decoding: decode(input) with no options. Passing `{ stream: true }` — the WHATWG mechanism for feeding chunks incrementally while carrying partial code points across calls — throws a TypeError, because stateful/incremental decoding is not implemented in the module host.","triggerScenarios":"decoder.decode(chunk, { stream: true }) inside incremental parsers ported into a SpacetimeDB V8 module: NDJSON/CSV readers, ReadableStream pipelines, and any loop that decodes byte chunks as they arrive.","commonSituations":"Porting Node stream-processing code into a module; libraries like ndjson parsers that depend on streaming TextDecoder semantics.","solutions":["Accumulate Uint8Array chunks in a buffer and call decode() once on the complete payload","Split on byte boundaries (e.g. newline bytes) manually, then decode each complete slice without options","Keep incremental text parsing on the client side rather than inside the module"],"exampleFix":"// before\nlet text = '';\nfor (const chunk of chunks) {\n  text += dec.decode(chunk, { stream: true }); // TypeError in module\n}\n\n// after\nconst parts: Uint8Array[] = [];\nfor (const chunk of chunks) parts.push(chunk);\nconst text = dec.decode(concatBytes(parts)); // one-shot, no options","handlingStrategy":"fallback","validationCode":"function decodeSafe(dec: TextDecoder, bytes: Uint8Array, opts: { stream?: boolean } = {}): string {\n  // fallback: the module builtin has no streaming mode; buffer and decode once\n  if (opts.stream) buffer.push(bytes); // caller flushes later with decodeSafe(dec, flush(), {})\n  return opts.stream ? '' : dec.decode(concatBytes(buffer.splice(0)));\n}","typeGuard":null,"tryCatchPattern":"try {\n  text = dec.decode(chunk, { stream: true });\n} catch (e) {\n  if (e instanceof TypeError) {\n    pending.push(chunk); // fall back to buffering\n    text = '';\n  }\n}","preventionTips":["Design module parsers around complete byte buffers, not streaming decode","Split streams on byte delimiters before decoding","Keep incremental text pipelines on the client side"],"tags":["textdecoder","streaming","v8","module","typescript"],"backgroundTag":"unsupported-api-option","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}