-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explore WebAssembly support #667
Comments
Hi @brandonros! Welcome to ureq! I have never used WebAssembly myself, so I don't actually know what would be required to make that work. The A possible direction for a ureq 3.0, would be to isolate the HTTP request/response function into a Sans IO pattern backing library without allocations, deliberately target no_std and webassembly. Then make nice higher level wrappers for std, no_std and webasm that sits on the same core. |
I'm curious @brandonros, what's the use case for using ureq in WebAssembly? If it's useful, we could probably do something where all the meaningful features are stubbed out to I do really like the idea of making a no_std version of ureq (with more user-friendly features stacked on top when std is present). |
@jsha i've been thinking about the no_std thing. Here's an experiment just fleshing out what a no_std low level API could look like: https://github.com/algesten/h1-call Design goals:
I've fleshed out how this could look with HTTP/1.0 – but it looks pretty promising, albeit it's a type soup. |
You're probably right. My "vision"/idea was probably due to a lack of understanding on how things should be done in write once, be able to run it backend (native Rust binary) and/or in the browser with |
Are there any updates on this? |
@dipankardas011 I think we need a ureq 3.0 to make this work. I'm thinking there needs to be a clean separation between connection/transport handling and the http1.1 logic. I'm in the process of structuring the underpinnings of such a rewrite, but it's slow work. Currently my main thinking is in this branch: https://github.com/algesten/hoot The structure I have in mind is roughly that hoot is Sans-IO http1.1 impl leaving connection/transport handling to a higher layer in the ureq crate which means that can be realized either as TcpSocket or whatever is needed in webasm. |
Np will wait |
ureq used to build on wasm, but apparently it never actually worked: algesten/ureq#667 Now it no longer builds, so I've removed it from CI. ``` error: the wasm*-unknown-unknown targets are not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support Error: --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.15/src/lib.rs:342:9 | 342 | / compile_error!("the wasm*-unknown-unknown targets are not supported by \ 343 | | default, you may need to enable the \"js\" feature. \ 344 | | For more information see: \ 345 | | https://docs.rs/getrandom/#webassembly-support"); | |________________________________________________________________________^ error[E0433]: failed to resolve: use of undeclared crate or module `imp` Error: --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.15/src/lib.rs:398:9 | 398 | imp::getrandom_inner(dest)?; | ^^^ use of undeclared crate or module `imp` ```
ureq used to build on wasm, but apparently it never actually worked: algesten/ureq#667 Now it no longer builds, so I've removed it from CI. ``` error: the wasm*-unknown-unknown targets are not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support Error: --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.15/src/lib.rs:342:9 | 342 | / compile_error!("the wasm*-unknown-unknown targets are not supported by \ 343 | | default, you may need to enable the \"js\" feature. \ 344 | | For more information see: \ 345 | | https://docs.rs/getrandom/#webassembly-support"); | |________________________________________________________________________^ error[E0433]: failed to resolve: use of undeclared crate or module `imp` Error: --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.15/src/lib.rs:398:9 | 398 | imp::getrandom_inner(dest)?; | ^^^ use of undeclared crate or module `imp` ```
ureq used to build on wasm, but apparently it never actually worked: algesten/ureq#667 Now it no longer builds, so I've removed it from CI. ``` error: the wasm*-unknown-unknown targets are not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support Error: --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.15/src/lib.rs:342:9 | 342 | / compile_error!("the wasm*-unknown-unknown targets are not supported by \ 343 | | default, you may need to enable the \"js\" feature. \ 344 | | For more information see: \ 345 | | https://docs.rs/getrandom/#webassembly-support"); | |________________________________________________________________________^ error[E0433]: failed to resolve: use of undeclared crate or module `imp` Error: --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.15/src/lib.rs:398:9 | 398 | imp::getrandom_inner(dest)?; | ^^^ use of undeclared crate or module `imp` ```
ureq used to build on wasm, but apparently it never actually worked: algesten/ureq#667 Now it no longer builds, so I've removed it from CI. ``` error: the wasm*-unknown-unknown targets are not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support Error: --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.15/src/lib.rs:342:9 | 342 | / compile_error!("the wasm*-unknown-unknown targets are not supported by \ 343 | | default, you may need to enable the \"js\" feature. \ 344 | | For more information see: \ 345 | | https://docs.rs/getrandom/#webassembly-support"); | |________________________________________________________________________^ error[E0433]: failed to resolve: use of undeclared crate or module `imp` Error: --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.15/src/lib.rs:398:9 | 398 | imp::getrandom_inner(dest)?; | ^^^ use of undeclared crate or module `imp` ```
ureq used to build on wasm, but apparently it never actually worked: algesten/ureq#667 Now it no longer builds, so I've removed it from CI. ``` error: the wasm*-unknown-unknown targets are not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support Error: --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.15/src/lib.rs:342:9 | 342 | / compile_error!("the wasm*-unknown-unknown targets are not supported by \ 343 | | default, you may need to enable the \"js\" feature. \ 344 | | For more information see: \ 345 | | https://docs.rs/getrandom/#webassembly-support"); | |________________________________________________________________________^ error[E0433]: failed to resolve: use of undeclared crate or module `imp` Error: --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.15/src/lib.rs:398:9 | 398 | imp::getrandom_inner(dest)?; | ^^^ use of undeclared crate or module `imp` ```
I would love for someone to try out how far away we are from running on WebAssembly. The new |
I just tried again with
Should I be trying a different version? I think |
Hm. Well. The main branch is quite a bit ahead now. But I don't imagine this specific problem is solved. So I guess parts of std are off limits in webasm? |
small update I get further now, some kind of |
yeah, you'd basically need to make ureq https://github.com/search?q=repo%3Aseanmonstar%2Freqwest%20wasm&type=code |
Yeah. I think it's not miles away from no_std since I believe we can also use the alloc crate. The default transports would be excluded and some new Transport be implemented. |
I think I made an important stepping stone in algesten/ureq-proto#6 |
Some work in #900 |
I don't know why I expected this to work with WebAssembly (it compiles for the
wasm32-unknown-unknown
target if you disable any TLS/SSL features).But you will get to JavaScript layer and have one of what I guess is many issues (how would it know to do HTTP over
fetch()
?):Which comes from
I read you can use Chrono::Duration (which does support WASM) but AgentBuilder would need to accept non std::time::Duration?
The text was updated successfully, but these errors were encountered: