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

Fix wasm32 build #208

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ jobs:
uses: taiki-e/install-action@cargo-hack
- name: test
run: cargo hack test --feature-powerset -p reqwest-middleware
check-wasm32-reqwest-middleware:
name: Run `cargo check` for `reqwest-middleware` on `wasm32-unknown-unknown`
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: actions-rs/cargo@v1
with:
command: build
args: --target wasm32-unknown-unknown -p reqwest-middleware --all-features
test-features-retry:
name: Run test suite for `reqwest-retry` with every feature combination
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions reqwest-middleware/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Fixed wasm32 by disabling incompatible parts. On that target, `ClientWithMiddleware` is no longer
a Tower service and has no `ClientWithMiddleware::timeout` function.

## [0.4.0] - 2024-11-08

Expand Down
2 changes: 2 additions & 0 deletions reqwest-middleware/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ impl fmt::Debug for ClientWithMiddleware {
}
}

#[cfg(not(target_arch = "wasm32"))]
mod service {
use std::{
future::Future,
Expand Down Expand Up @@ -422,6 +423,7 @@ impl RequestBuilder {
/// The timeout is applied from when the request starts connecting until the
/// response body has finished. It affects only this request and overrides
/// the timeout configured using `ClientBuilder::timeout()`.
#[cfg(not(target_arch = "wasm32"))]
pub fn timeout(self, timeout: std::time::Duration) -> Self {
RequestBuilder {
inner: self.inner.timeout(timeout),
Expand Down