diff --git a/sdk/src/client/builder.rs b/sdk/src/client/builder.rs index fc5026fb18..576042a576 100644 --- a/sdk/src/client/builder.rs +++ b/sdk/src/client/builder.rs @@ -310,7 +310,7 @@ impl ClientBuilder { sender: RwLock::new(mqtt_event_tx), receiver: RwLock::new(mqtt_event_rx), }, - last_sync: std::sync::Mutex::new(None), + last_sync: tokio::sync::Mutex::new(None), }), }; diff --git a/sdk/src/client/core.rs b/sdk/src/client/core.rs index 9d4830e6ca..fb34c5764c 100644 --- a/sdk/src/client/core.rs +++ b/sdk/src/client/core.rs @@ -55,7 +55,7 @@ pub struct ClientInner { #[cfg(feature = "mqtt")] pub(crate) mqtt: MqttInner, #[cfg(target_family = "wasm")] - pub(crate) last_sync: std::sync::Mutex>, + pub(crate) last_sync: tokio::sync::Mutex>, } #[derive(Default)] @@ -107,7 +107,7 @@ impl ClientInner { #[cfg(target_family = "wasm")] { let current_time = crate::utils::unix_timestamp_now().as_secs() as u32; - if let Some(last_sync) = *self.last_sync.lock().unwrap() { + if let Some(last_sync) = *self.last_sync.lock().await { if current_time < last_sync { return Ok(self.network_info.read().await.clone()); } @@ -115,7 +115,7 @@ impl ClientInner { let info = self.get_info().await?.node_info; let mut client_network_info = self.network_info.write().await; client_network_info.protocol_parameters = info.protocol.clone(); - *self.last_sync.lock().unwrap() = Some(current_time + CACHE_NETWORK_INFO_TIMEOUT_IN_SECONDS); + *self.last_sync.lock().await = Some(current_time + CACHE_NETWORK_INFO_TIMEOUT_IN_SECONDS); } Ok(self.network_info.read().await.clone())