diff --git a/bindings/matrix-sdk-crypto-js/CHANGELOG.md b/bindings/matrix-sdk-crypto-js/CHANGELOG.md index 7e0703be2..ef6a4be1b 100644 --- a/bindings/matrix-sdk-crypto-js/CHANGELOG.md +++ b/bindings/matrix-sdk-crypto-js/CHANGELOG.md @@ -1,3 +1,8 @@ +# v0.1.0-alpha.7 + +- In `OlmMachine.getUserDevices`, wait a limited time for any in-flight + device-list updates to complete. + # v0.1.0-alpha.6 - Add new accessor `InboundGroupSession.senderKey`. diff --git a/bindings/matrix-sdk-crypto-js/src/machine.rs b/bindings/matrix-sdk-crypto-js/src/machine.rs index 99fb0b3d7..1a3163647 100644 --- a/bindings/matrix-sdk-crypto-js/src/machine.rs +++ b/bindings/matrix-sdk-crypto-js/src/machine.rs @@ -1,6 +1,6 @@ //! The crypto specific Olm objects. -use std::{collections::BTreeMap, ops::Deref}; +use std::{collections::BTreeMap, ops::Deref, time::Duration}; use futures_util::StreamExt; use js_sys::{Array, Function, Map, Promise, Set}; @@ -582,7 +582,10 @@ impl OlmMachine { let me = self.inner.clone(); future_to_promise::<_, device::UserDevices>(async move { - Ok(me.get_user_devices(&user_id, None).await.map(Into::into)?) + // wait for up to a second for any in-flight device list requests to complete. + // The reason for this isn't so much to avoid races (some level of raciness is + // inevitable for this method) but to make testing easier. + Ok(me.get_user_devices(&user_id, Some(Duration::from_secs(1))).await.map(Into::into)?) }) }