Open usagi opened 2 years ago
Try building with default-features = false, features = ["h1-client"]
Oh, wasm-client
is deprecated? Surely, cargo check
and cargo test
work as expected in surf/wasm-test if modified from wasm-client
to h1-client
. My problem has been solved thanks to https://github.com/http-rs/surf/issues/345#issuecomment-1130317260 and I can now use the latest version of surf!
But, just in case, this Issue is maybe useful for wasm users who try to use surf newbies and hasn't used it in a long time. Should keep the issue until update the related documents and tests and examples? I will leave it to authors to decide when to close the issue.
Thank you! 💖
Honestly I wasn't really sure if that would work but cool to know that it did.
Same version and configuration, but didn't work for me, on macOS.
Error:
error: the wasm32-unknown-unknown target is not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support
--> /Users/bytedance/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.8/src/lib.rs:263:9
|
263 | / compile_error!("the wasm32-unknown-unknown target is not supported by \
264 | | default, you may need to enable the \"js\" feature. \
265 | | For more information see: \
266 | | https://docs.rs/getrandom/#webassembly-support");
| |________________________________________________________________________^
Compiling foreign-types v0.3.2
Compiling httparse v1.8.0
error[E0433]: failed to resolve: use of undeclared crate or module `imp`
--> /Users/bytedance/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.8/src/lib.rs:290:5
|
290 | imp::getrandom_inner(dest)
| ^^^ use of undeclared crate or module `imp`
For more information about this error, try `rustc --explain E0433`.
error: could not compile `getrandom` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
Error: Compilation of your program failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
full command: "cargo" "build" "--tests" "--target" "wasm32-unknown-unknown"
Repro
cargo new surf-wasm-test --lib
crate-type = [ "cdylib" ]
in[lib]
surf = { version = "2.3.2", fefault-features = false, features = [ "wasm-client" ] }
in[dependencies]
cargo check --target wasm32-unknown-unknown
, and then it occur the error.Error