From 36e3039d73b51e64e39e247c98d316883e37beb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Sun, 7 Feb 2021 12:53:06 +0100 Subject: [PATCH] matrix-sdk: Disable request retrying for wasm for now Backoff supports the retry method for futures only for non-wasm targets for now, thus we're going to disable it until that changes. --- matrix_sdk/Cargo.toml | 2 +- matrix_sdk/src/http_client.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/matrix_sdk/Cargo.toml b/matrix_sdk/Cargo.toml index bca1f66b..95ffc18b 100644 --- a/matrix_sdk/Cargo.toml +++ b/matrix_sdk/Cargo.toml @@ -50,7 +50,7 @@ default_features = false version = "0.11.0" default_features = false -[dependencies.backoff] +[target.'cfg(not(target_arch = "wasm32"))'.dependencies.backoff] git = "https://github.com/ihrwein/backoff" features = ["tokio"] rev = "fa3fb91431729ce871d29c62b93425b8aec740f4" diff --git a/matrix_sdk/src/http_client.rs b/matrix_sdk/src/http_client.rs index 60a89e97..cd7d6265 100644 --- a/matrix_sdk/src/http_client.rs +++ b/matrix_sdk/src/http_client.rs @@ -14,9 +14,9 @@ use std::{convert::TryFrom, fmt::Debug, sync::Arc}; -#[cfg(not(test))] +#[cfg(all(not(test), not(target_arch = "wasm32")))] use backoff::{future::retry, Error as RetryError, ExponentialBackoff}; -#[cfg(not(test))] +#[cfg(all(not(test), not(target_arch = "wasm32")))] use http::StatusCode; use http::{HeaderValue, Method as HttpMethod, Response as HttpResponse}; use reqwest::{Client, Response}; @@ -30,7 +30,9 @@ use matrix_sdk_common::{ use crate::{error::HttpError, ClientConfig, OutgoingRequest, Session}; +#[cfg(not(target_arch = "wasm32"))] const DEFAULT_CONNECTION_TIMEOUT: Duration = Duration::from_secs(5); +#[cfg(not(target_arch = "wasm32"))] const DEFAULT_REQUEST_TIMEOUT: Duration = Duration::from_secs(10); /// Abstraction around the http layer. The allows implementors to use different @@ -235,7 +237,7 @@ async fn response_to_http_response( .expect("Can't construct a response using the given body")) } -#[cfg(test)] +#[cfg(any(test, target_arch = "wasm32"))] async fn send_request( client: &Client, request: http::Request>, @@ -247,7 +249,7 @@ async fn send_request( Ok(response_to_http_response(response).await?) } -#[cfg(not(test))] +#[cfg(all(not(test), not(target_arch = "wasm32")))] async fn send_request( client: &Client, request: http::Request>,