TypeScript module TextDecoder rejects valid utf8/utf-16le labels, breaking h3-js imports
Summary
SpacetimeDB 2.10.1 TypeScript modules throw during module evaluation when a dependency constructs TextDecoder with the valid web encoding labels utf8 or utf-16le. This prevents unmodified [email protected] from loading server-side.
I searched existing issues/PRs for the exception text, TextDecoder, utf-16le, and h3-js. PR #3800 documents that the V8 host implements a subset of the API, but I did not find an issue covering these rejected labels.
Environment
- SpacetimeDB CLI / standalone: 2.10.1
spacetimedbnpm package: 2.10.1h3-js: 4.5.0- TypeScript: 5.6.3
- Node.js: 24.21.0
- Windows local standalone server
Minimal reproduction
Create a TypeScript module and install [email protected]:
import { schema } from 'spacetimedb/server';
import { latLngToCell } from 'h3-js';
const spacetimedb = schema({});
export default spacetimedb;
export const probe = spacetimedb.reducer(() => {
console.info(latLngToCell(37.775938728915946, -122.41795063018799, 9));
});Run spacetime build.
Actual behavior
The browser bundle selected for h3-js fails first at:
new TextDecoder("utf8")with:
Error: Uncaught RangeError: The encoding label provided is invalid
at TextDecoder (internal:text_encoding.js:32:13)
at .../h3-js/dist/browser/h3-js.es.js
Build finished successfully.Changing that label to utf-8 reaches a second failure at:
new TextDecoder("utf-16le")with the same exception. The UTF16Decoder variable in this generated bundle is unused, but its eager construction still prevents module loading.
The CLI also exits successfully and prints Build finished successfully after the uncaught module-evaluation exception, which can make the failed build look healthy in automation.
Expected behavior
TextDecoder should accept the labels required by the WHATWG Encoding Standard, including the utf8 alias and utf-16le, or the supported subset should be documented and dependency evaluation should fail the build with a non-zero exit status.
Verified workaround
Applying these two changes to the dependency makes the module build, publish, and execute latLngToCell and gridDisk successfully:
-new TextDecoder("utf8")
+new TextDecoder("utf-8")
-new TextDecoder("utf-16le")
+undefinedThis workaround was verified by publishing to the 2.10.1 local server and executing reducers, but it requires maintaining a downstream package patch.
Source: clockworklabs/SpacetimeDB