The playground reads ICU's data on a module's first use of ICU, with a synchronous request in its worker
Date: 2026-12-03
Area: website
Refines: ADR 0236, whose browser runs had no Intl
locale data
Related: ADR 0245, ADR 0237
Context
Since ADR 0245 the wasm32-wasip1 modules link ICU and read its data from /.goccia/icu/icudt79l.dat, a file their
host offers, on their first use of ICU: Intl, or a Temporal calendar other than ISO 8601. The release archive carries
the file under icu/: 9.6 MB, 4.2 MB with gzip, which a host compresses in transit, against 3.9 MB for
GocciaRunner.wasm. Most playground scripts use neither.
A run's time is limited twice: the engine's --timeout of 5 s, read from WASI's monotonic clock, and the page's kill
timer of 6.5 s, which ends the worker.
A WASI call must answer before it returns, and the browser's WASI host runs in a dedicated worker, which may block.
The fetch device already performs a request with a synchronous XMLHttpRequest there (ADR 0237).
Decision
- The site stages the file with the modules.
scripts/fetch-binaries.tscopies a version'sicu/icudt*l.datbeside its modules, under the same prefix of the archive's SHA-256, and records its URL and gzip size in the manifest'swasm.icuData. A manifest entry staged before this revision is staged again. - A run is offered it at
/.goccia/icu. The page passes the URL with the module's to the worker, and the worker's WASI host offers a read-only directory holding one file of that name, after the run's own directory and before the fetch device's. - The file is read when the module opens it. The host asks
src/lib/icu-data.tsfor the bytes then, which reads them with a synchronousXMLHttpRequestin the worker and keeps them for the worker's life. Its URL is served with the modules' long-lived caching, so another worker gets it from the HTTP cache. - The run's time stands still while the file loads. The host's monotonic clock leaves out the time the read takes,
so the engine's
--timeoutdoes not count it, and the worker tells the page when the read starts and ends, so the kill timer pauses. The page's loading limit (LOAD_LIMIT_MS, 120 s) applies to the read instead, and the read itself gives up after 60 s. - A failed read leaves the run without ICU. The file is then absent, and the module runs without locale data as a version without the file does.
Consequences
- A browser run formats with the locale data of the 22 locales the file holds, as a server run formats with its system's ICU.
- A run that never uses ICU downloads nothing more. The first run that does waits for the file, about 4.2 MB, on a clock that does not count the wait.
- A version whose archive has no
icu/runs as before. - Bun has no
XMLHttpRequest, so the worker's read is tested against a stand-in, and the module's use of the file throughrunWasmRequest, with the file read from disk.