Skip to content

TypeScript module throws RangeError: Internal error. Icu error. procedure when trying to use http #3926

@doodlechaos

Description

@doodlechaos

Bug: TypeScript module V8 runtime throws RangeError: Internal error. Icu error. on Windows (breaks Intl/URL and ctx.http.fetch)

Summary
On Windows, a SpacetimeDB TypeScript server module throws RangeError: Internal error. Icu error. when calling ICU-dependent JS functionality (e.g. "a".localeCompare("b")) and also when constructing a URL (new URL("https://example.com")). This breaks ctx.http.fetch(...) (HTTP requests), so TS procedures cannot call external apis in some cases (e.g. OpenAI in my use case).

Environment

  • OS: Windows 11
spacetime Path: C:\Users\merob\AppData\Local\SpacetimeDB\bin\current\spacetimedb-cli.exe
Commit: bbfa851b45db7096aa2a69d7dbad84f52983559f
spacetimedb tool version 1.11.1; spacetimedb-lib version 1.11.1;

Impact

  • Any ICU/Intl usage appears broken (localeCompare, likely Intl.*, toLocaleString, etc.)
  • URL parsing/creation is broken (new URL(...))
  • ctx.http.fetch(...) fails with the same ICU error, preventing HTTP requests from procedures

Minimal reproduction
Create a TS module with the following code and call the procedure from a client:

// spacetimedb/src/command.ts
import { t } from "spacetimedb/server";

export function registerCommandProcedures(db: { procedure: Function }) {
  db.procedure("icu_smoketest1", {}, t.string(), (_ctx: any) => {
    try {
      "a".localeCompare("b"); // << Triggers the error. This does too: new URL("https://example.com"); //<< Triggers the error
      return "OK";
    } catch (e: any) {
      return `ICU FAIL: ${String(e?.message ?? e)}`;
    }
  });
}

Client:

  async function onTestClick() {
    console.log("Sending test command to server");
    let result = await conn.procedures.icuSmoketest1({});
    console.log("Result:", result);
  }
Sending test command to server
App.svelte:52 Result: ICU FAIL: Internal error. Icu error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions