Skip to content

Make Rust crate wasm32-compatible and re-add wasm CI check #174

Description

@AndreaDiazCorreia

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ciContinuous integration / build automation

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions