Context
CI (added in #173, part of #151) intentionally omits cargo check --target wasm32-unknown-unknown from the Rust job because the crate does not currently compile to wasm32-unknown-unknown. Gating on it would leave the Rust job permanently red.
This tracks the work to make the crate wasm-compatible and then re-enable the check.
Root cause
tokio is declared native-only in rust/Cargo.toml:
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
…but it is imported and used unconditionally across the codebase, e.g. rust/src/api/{orders,messages,identity,logging,disputes,nwc,reputation,settings,nostr}.rs, rust/src/db/app_db.rs, rust/src/mostro/session.rs, and rust/src/nostr/relay_pool.rs. Compiling for wasm32 yields ~50 E0433: cannot find crate tokio errors, plus E0277: [RelayInfo] !Sized errors in relay_pool.rs.
The web target is intended: rust/Cargo.toml has [target.'cfg(target_arch = "wasm32")'.dependencies] (indexed_db_futures, wasm-bindgen-futures), and the architecture docs describe IndexedDB persistence on web.
Scope
- cfg-gate or abstract the native async runtime usage (sync primitives,
tokio::spawn, tokio::time, tokio::fs) so the crate compiles for wasm32.
- Resolve the
[RelayInfo]: !Sized issues in relay_pool.rs.
- Re-add
cargo check --target wasm32-unknown-unknown (with the wasm32-unknown-unknown target install) to the Rust CI job.
- Fix the same check in
.githooks/pre-commit, which currently also cannot pass.
Reference
Context
CI (added in #173, part of #151) intentionally omits
cargo check --target wasm32-unknown-unknownfrom the Rust job because the crate does not currently compile towasm32-unknown-unknown. Gating on it would leave the Rust job permanently red.This tracks the work to make the crate wasm-compatible and then re-enable the check.
Root cause
tokiois declared native-only inrust/Cargo.toml:…but it is imported and used unconditionally across the codebase, e.g.
rust/src/api/{orders,messages,identity,logging,disputes,nwc,reputation,settings,nostr}.rs,rust/src/db/app_db.rs,rust/src/mostro/session.rs, andrust/src/nostr/relay_pool.rs. Compiling forwasm32yields ~50E0433: cannot find crate tokioerrors, plusE0277: [RelayInfo] !Sizederrors inrelay_pool.rs.The web target is intended:
rust/Cargo.tomlhas[target.'cfg(target_arch = "wasm32")'.dependencies](indexed_db_futures,wasm-bindgen-futures), and the architecture docs describe IndexedDB persistence on web.Scope
tokio::spawn,tokio::time,tokio::fs) so the crate compiles forwasm32.[RelayInfo]: !Sizedissues inrelay_pool.rs.cargo check --target wasm32-unknown-unknown(with thewasm32-unknown-unknowntarget install) to the Rust CI job..githooks/pre-commit, which currently also cannot pass.Reference