Skip to content
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

feat(wasm): add support for the stable target wasm32-wasip2 #2453

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

brooksmtownsend
Copy link

@brooksmtownsend brooksmtownsend commented Oct 21, 2024

Fixes #2294

Depends on servo/rust-url#983

This PR, in order of commits:

  • Adds target conditionals to separate the compilation of reqwest in the general wasm32 OS and the wasm32-wasip2 target (which is now a tier 2 target and Rust stable in 1.82)
  • Adds .vscode to the .gitignore (I can remove this if it's undesired)
  • Adds wasm32-wasip2 implementations for reqwest so that you can compile WebAssembly components and make outgoing requests that compile down to wasi:http bindings
    - This commit also adds a patch for crates.io that depends on fix: support wasm32-wasip2 on the stable channel servo/rust-url#983, which is why this PR is a draft. There is no significant functionality change upstream to make the wasm32-wasip2 target work for the url crate, just a change to remove an unstable feature flag.
  • Adds an example wasm_component to illustrate how this crate can be used in the context of a wasm32-wasip2 program.

I've attempted to bring over the minimal implementations into the wasm32-wasip2 code, e.g. no multipart support, to keep the review focused and simple to start. If any of these need to be added, I'm happy to add follow-up commits after the review.

Signed-off-by: Brooks Townsend <[email protected]>

refactor(wasm): add wasm mod

Signed-off-by: Brooks Townsend <[email protected]>
Signed-off-by: Brooks Townsend <[email protected]>
@brooksmtownsend brooksmtownsend force-pushed the feat/wasi-p2-component-stable-blocking branch from 1379d90 to 7edd47e Compare October 22, 2024 13:12
Signed-off-by: Brooks Townsend <[email protected]>

cleanup extraneous comment

Signed-off-by: Brooks Townsend <[email protected]>

feat: give back incoming body too

Signed-off-by: Brooks Townsend <[email protected]>

deps(url): remove patch

Signed-off-by: Brooks Townsend <[email protected]>
Signed-off-by: Brooks Townsend <[email protected]>

example cleanup extra blocking feature

Signed-off-by: Brooks Townsend <[email protected]>

use body example

Signed-off-by: Brooks Townsend <[email protected]>

deps(url): remove patch

Signed-off-by: Brooks Townsend <[email protected]>
@brooksmtownsend brooksmtownsend force-pushed the feat/wasi-p2-component-stable-blocking branch from 7edd47e to 3b3c99e Compare November 4, 2024 15:00
@brooksmtownsend
Copy link
Author

brooksmtownsend commented Dec 17, 2024

Apologies for letting this go stale here, I haven't had the time to really shore this one up. I think there's a lot of promise in this approach, and I also don't want to overindex on supporting wasi:[email protected] if we could possibly support it using a combination of the stdlib and tokio in this crate.

I think in the shorter term what would make this PR a candidate for review and merging would either be:

  1. Integration into the async reqwest using a wasm-compatible async runtime (like tokio)
  2. Integration into the blocking reqwest as-is (which I've looked into, and may be more complicated than first meets the eye)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support WebAssembly Component bindings, aka wasip2, in addition to javascript bindings
1 participant