Skip to content

[wasm-build] cargo check --target wasm32-unknown-unknown -p willow-network --all-features fails on tokio import #502

@intendednull

Description

@intendednull

Symptom

cargo check --target wasm32-unknown-unknown -p willow-network --all-features fails because crates/network/src/mem.rs uses tokio::sync::broadcast + tokio::select! without a cfg(not(target_arch = "wasm32")) gate. Reproduces clean on main @ 0b051c1.

Why this isn't caught today

The project's actual wasm gate (just check-wasm, justfile:144) runs cargo check --target wasm32-unknown-unknown without --all-features. MemNetwork is gated behind the test-utils feature and is opt-in for native test consumers; under default features it's not compiled, so the wasm gate stays green.

Why anyone would hit it

A future contributor running cargo check --all-features --target wasm32-unknown-unknown (e.g. for a workspace-wide audit) trips on this. Discovered while running #258's local merge gate — implementer flagged it as pre-existing, out of scope for the 2-line _ => exhaustive-match fix.

Suggested fix

Two reasonable options:

  1. Gate mem.rs behind #[cfg(not(target_arch = "wasm32"))] at the module / feature level so the test-utils feature still compiles cleanly under wasm (no-op on wasm, since MemNetwork is a native-only test double anyway). Cleanest option — matches the documented test-double role.
  2. Drop MemNetwork from --all-features on wasm by making the test-utils feature itself native-only via a target-conditional dep / cfg gate.

Option 1 is more surgical. Real production wasm wires IrohNetwork; MemNetwork has no wasm consumer.

Verify

cargo check --target wasm32-unknown-unknown -p willow-network --all-features  # expect: success after fix
just check-wasm                                                                # expect: still passes (regression check)

Refs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions