You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.4 KiB
2.4 KiB
| title | status | type | priority | created_at | updated_at |
|---|---|---|---|---|---|
| [TRIAGE] NanoID crate WASM compatibility with workers-rs target | completed | task | critical | 2026-03-10T23:32:08Z | 2026-03-10T23:32:08Z |
Decision: Option 2 — uuid v4
The nanoid crate (v0.4.0) depends on rand ^0.8, which uses thread_rng() (thread-local RNG).
Thread-local storage is unreliable in wasm32-unknown-unknown, and the underlying getrandom
wasm_js feature is explicitly discouraged in libraries by the getrandom maintainers.
uuid = { version = "1", features = ["v4", "serde"] } with getrandom = { version = "0.2", features = ["js"] } (wasm32 cfg section only) is the proven, zero-risk approach for
Cloudflare Workers. UUID v4 produces 36-char hyphenated IDs — slightly longer than NanoID's 21
chars, but negligible in practice and universally supported.
Created ticket
7a0d9f — "Implement generate_id() in src/lib.rs — UUID v4 for WASM-compatible quote IDs"
generate_id()insrc/lib.rsreturnsuuid::Uuid::new_v4().to_string()- Cargo.toml adds
uuidto[dependencies]andgetrandom/jsunder[target.'cfg(target_arch = "wasm32")'.dependencies] - Ticket 05f8ae (PUT handler) and 1f5bb5 (Cargo.toml) updated to reference this approach
Updated tickets
- 05f8ae: "Generate a NanoID for the quote ID" → use
generate_id()from lib.rs (UUID v4) - 1f5bb5: Add
uuid = { version = "1", features = ["v4", "serde"] }to [dependencies]; addgetrandom = { version = "0.2", features = ["js"] }under wasm32 cfg