{"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/524b4487d949b61a07d4f39c862d1290259dfd20/crates/core/src/host/v8/builtins/text_encoding.js#L19-L55","documentation":"The built-in TextDecoder polyfill in the SpacetimeDB V8 host supports only the fatal option. If options.ignoreBOM is truthy, the constructor throws TypeError('Option ignoreBOM not supported'), and the ignoreBOM getter is hardwired to return false (BOM kept as U+FEFF, the encoding-spec default).","triggerScenarios":"Calling new TextDecoder('utf-8', { ignoreBOM: true }) with any truthy value; note that { ignoreBOM: false } is accepted since only truthy values hit the check.","commonSituations":"Copying browser code that strips a byte-order mark via ignoreBOM; decoding files that carry BOMs (Windows-authored JSON/CSV) inside a module.","solutions":["Omit the ignoreBOM option entirely — it is not configurable in this polyfill","Strip the BOM bytes yourself before decoding: check for 0xEF 0xBB 0xBF and subarray(3)","Do BOM-sensitive decoding outside the module and send clean UTF-8 in"],"exampleFix":"// before\nconst text = new TextDecoder('utf-8', { ignoreBOM: true }).decode(bytes);\n\n// after\nconst noBom = bytes[0] === 0xEF && bytes[1] === 0xBB && bytes[2] === 0xBF ? bytes.subarray(3) : bytes;\nconst text = new TextDecoder('utf-8').decode(noBom);","handlingStrategy":"validation","validationCode":"// Only pass options the polyfill supports:\nconst dec = new TextDecoder('utf-8', { fatal: opts.fatal }); // ignoreBOM intentionally dropped","typeGuard":"function isSupportedDecoderOptions(o: { fatal?: boolean; ignoreBOM?: boolean }): boolean {\n  return !o.ignoreBOM; // truthy ignoreBOM is the only rejected option\n}","tryCatchPattern":"try {\n  dec = new TextDecoder('utf-8', options);\n} catch (e) {\n  if (e instanceof TypeError && /ignoreBOM/.test(e.message)) {\n    const { ignoreBOM: _drop, ...rest } = options;\n    dec = new TextDecoder('utf-8', rest);\n  } else throw e;\n}","preventionTips":["Never forward user-supplied option bags straight into TextDecoder; whitelist keys","Strip BOM bytes manually when needed rather than relying on ignoreBOM","Wrap decoder creation in a factory that documents the supported subset"],"tags":["javascript","textdecoder","encoding","bom","polyfill","v8"],"backgroundTag":"unsupported-constructor-option","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}