From 63ba510b091717232d834bcb2adc175f8dc6d705 Mon Sep 17 00:00:00 2001 From: Rushmore Mushambi Date: Sat, 14 Jan 2023 21:56:40 +0200 Subject: [PATCH] Use `spawn_local` instead of `tokio::spawn` on WebAssembly (#1595) --- lib/src/api/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/api/mod.rs b/lib/src/api/mod.rs index 12c48f30..02c91702 100644 --- a/lib/src/api/mod.rs +++ b/lib/src/api/mod.rs @@ -22,6 +22,10 @@ use std::future::IntoFuture; use std::marker::PhantomData; use std::pin::Pin; use std::sync::Arc; +#[cfg(not(target_arch = "wasm32"))] +use tokio::spawn; +#[cfg(target_arch = "wasm32")] +use wasm_bindgen_futures::spawn_local as spawn; /// A specialized `Result` type pub type Result = std::result::Result; @@ -140,7 +144,7 @@ where { fn check_server_version(&self) { let conn = self.clone(); - tokio::spawn(async move { + spawn(async move { let (versions, build_meta) = SUPPORTED_VERSIONS; // invalid version requirements should be caught during development let req = VersionReq::parse(versions).expect("valid supported versions");