http-rs / http-rs/surf

unable to build with wasm32-wasi target

Open
#301 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.5k
Forks
128
PR merge metrics
No merged PRs in 30d

Description

I'm seeing if I can use surf with wasi. Unfortunately, the dependencies appear not to be correct, even with

[dependencies]
async-executor = "*"
futures-lite = "*"
surf = { version = "*", default-features = false, features = ["wasm-client"] }

I get a dependency on socket2

cargo tree --invert socket2 --target wasm32-wasi
socket2 v0.4.0
└── async-io v1.4.0
    ├── async-global-executor v2.0.2
    │   └── async-std v1.9.0
    │       ├── http-types v2.11.0
    │       │   ├── http-client v6.3.5
    │       │   │   └── surf v2.2.0
    │       │   │       └── try_wasi_async v0.1.0 (C:\Users\cataggar\rs\try_wasi_async)
    │       │   └── surf v2.2.0 (*)
    │       └── surf v2.2.0 (*)
    └── async-std v1.9.0 (*)

Test app is:

use async_executor::{Executor, Task};
use futures_lite::future;
use surf::Result;

fn main() -> Result<()> {
    let ex = Executor::new();
    let task: Task<Result<()>> = ex.spawn(async {
        let ip = surf::get("http://ip.jsontest.com/").await?.body_string().await?;
        println!("ip {}", &ip);
        Ok(())
    });
    future::block_on(ex.run(task))
}

Which I've pushed here: https://github.com/ctaggart/try_wasi_async

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided wasm32-wasi test app and run cargo tree --invert socket2 --target wasm32-wasi to trace the async-std, async-io, and socket2 dependency path. Inspect Surf's default-features = false and wasm-client configuration; done means the test app can build for wasm32-wasi without an incompatible socket2 dependency.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
build-system, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.