{"record":{"id":"a004fc054f3b48b5","repo":"clockworklabs/SpacetimeDB","slug":"option-ignorebom-not-supported","errorCode":null,"errorMessage":"Option 'ignoreBOM' not supported","messagePattern":"Option 'ignoreBOM' not supported","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"crates/core/src/host/v8/builtins/text_encoding.js","lineNumber":37,"sourceCode":"globalThis.TextDecoder = class TextDecoder {\n  /** @type {string} */\n  #encoding;\n\n  /** @type {boolean} */\n  #fatal;\n\n  /**\n   * @argument {string} label\n   * @argument {any} options\n   */\n  constructor(label = 'utf-8', options = {}) {\n    if (label !== 'utf-8') {\n      throw new RangeError('The encoding label provided is invalid');\n    }\n    this.#encoding = label;\n    this.#fatal = !!options.fatal;\n    if (options.ignoreBOM) {\n      throw new TypeError(\"Option 'ignoreBOM' not supported\");\n    }\n  }\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 = {}) {","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/core/src/host/v8/builtins/text_encoding.js#L19-L55","documentation":"The builtin TextDecoder constructor accepts only the `fatal` option; `ignoreBOM` is not implemented (the getter always reports false), and passing `{ ignoreBOM: true }` throws a TypeError immediately. The host deliberately keeps the decoder minimal, so BOM-handling options from the WHATWG spec are rejected rather than silently ignored.","triggerScenarios":"new TextDecoder('utf-8', { ignoreBOM: true }) — or an options object that always includes ignoreBOM — inside a SpacetimeDB V8 module; shared browser/Node encoding utilities passed through verbatim to the module.","commonSituations":"Code that relies on BOM-preserving decoders; polyfills and libraries that construct TextDecoder with the full options bag; copy-pasted MDN examples that pass ignoreBOM.","solutions":["Remove `ignoreBOM` from the options object — only `fatal` is accepted","Handle the BOM manually after decoding: strip or keep a leading \\uFEFF according to your needs","Keep encoding helpers platform-specific instead of sharing them byte-for-byte with the module"],"exampleFix":"// before\nconst dec = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); // TypeError\n\n// after\nconst dec = new TextDecoder('utf-8', { fatal: true });\nlet text = dec.decode(bytes);\nif (!keepBom) text = text.replace(/^\\uFEFF/, ''); // BOM handled manually","handlingStrategy":"validation","validationCode":"function safeDecoderOptions(o: { fatal?: boolean; ignoreBOM?: boolean } = {}) {\n  const out: { fatal?: boolean } = {};\n  if ('fatal' in o) out.fatal = o.fatal;\n  // ignoreBOM intentionally dropped: unsupported in SpacetimeDB modules\n  return out;\n}\nconst dec = new TextDecoder('utf-8', safeDecoderOptions(opts));","typeGuard":null,"tryCatchPattern":"try {\n  new TextDecoder('utf-8', opts);\n} catch (e) {\n  if (e instanceof TypeError) {\n    // retry with only { fatal }\n    new TextDecoder('utf-8', { fatal: !!opts.fatal });\n  }\n}","preventionTips":["Pass at most { fatal: true } to the builtin TextDecoder","Handle BOM bytes manually after decoding","Do not share browser encoding utilities verbatim with module code"],"tags":["textdecoder","options","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"}