clockworklabs/SpacetimeDB · error · TypeError
Option 'ignoreBOM' not supported
Error message
Option 'ignoreBOM' not supported
What it means
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.
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
Example fix
// before
const dec = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); // TypeError
// after
const dec = new TextDecoder('utf-8', { fatal: true });
let text = dec.decode(bytes);
if (!keepBom) text = text.replace(/^\uFEFF/, ''); // BOM handled manually Defensive patterns
Strategy: validation
Validate before calling
function safeDecoderOptions(o: { fatal?: boolean; ignoreBOM?: boolean } = {}) {
const out: { fatal?: boolean } = {};
if ('fatal' in o) out.fatal = o.fatal;
// ignoreBOM intentionally dropped: unsupported in SpacetimeDB modules
return out;
}
const dec = new TextDecoder('utf-8', safeDecoderOptions(opts)); Try / catch
try {
new TextDecoder('utf-8', opts);
} catch (e) {
if (e instanceof TypeError) {
// retry with only { fatal }
new TextDecoder('utf-8', { fatal: !!opts.fatal });
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Option 'stream' not supported
- The encoding label provided is invalid
- Math.random is not available in SpacetimeDB modules. Use…
- must export schema as default export
- Brotli compression is not supported by the runtime. Please…
AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20).
Data as JSON: /api/errors/a004fc054f3b48b5.
Report an issue: GitHub.
Appendix: source
Thrown at crates/core/src/host/v8/builtins/text_encoding.js:37
globalThis.TextDecoder = class TextDecoder {
/** @type {string} */
#encoding;
/** @type {boolean} */
#fatal;
/**
* @argument {string} label
* @argument {any} options
*/
constructor(label = 'utf-8', options = {}) {
if (label !== 'utf-8') {
throw new RangeError('The encoding label provided is invalid');
}
this.#encoding = label;
this.#fatal = !!options.fatal;
if (options.ignoreBOM) {
throw new TypeError("Option 'ignoreBOM' not supported");
}
}
get encoding() {
return this.#encoding;
}
get fatal() {
return this.#fatal;
}
get ignoreBOM() {
return false;
}
/**
* @argument {any} input
* @argument {any} options
*/
decode(input, options = {}) {View on GitHub (pinned to 6dee26c6ef)