Skip to content

Commit f446382

Browse files
committed
Revert "Remove uses of future_to_promise in machine.rs (#193)"
This reverts commit eea167e. Unfortunately, most of this change is unsound. With an explicit `future_to_promise`, we are able to clone the underlying `matrix_sdk_crypto::OlmMachine` (and its constituent `Arc`) *before* returning a Promise to the javascript, meaning even if the wrapping `matrix_sdk_crypto_wasm::OlmMachine` is dropped, the underlying `OlmMachine` hangs around. An `async` function does nothing until it is polled, meaning there is plenty of time for the Javascript to get hold of the Promise and drop its reference to the OlmMachine, before we try and clone it. I think it's fine if we let the Javascript finalizer manage cleanup; but we deliberately drop OlmMachine, in an attempt to get it to drop its indexeddb conneciton. I'd go so far as to say that wasm-bindgen's support for `#[wasm_bindgen]` on `async fn` (rustwasm/wasm-bindgen#1754) is fundamentally incompatible with an explicit call to `.free()` (or, in this case, `.close()`, which is the same thing.) Probably, the correct fix here is to improve the way we handle indexeddb connections (cf element-hq/element-web#25779), at which point we can remove the `.close()`/`.free()` calls, and reintroduce this. For now though, I'm going to back it out.
1 parent 4b42571 commit f446382

File tree

3 files changed

+324
-252
lines changed

3 files changed

+324
-252
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# UNRELEASED
22

3+
- Revert updates to generated typescript types, which could cause runtime
4+
errors.
5+
([#205](https://github.com/matrix-org/matrix-rust-sdk-crypto-wasm/pull/205))
6+
37
# matrix-sdk-crypto-wasm v14.0.0
48

59
- `CollectStrategy.deviceBasedStrategy` is deprecated, and replaced by other methods in `CollectStrategy`.

0 commit comments

Comments
 (0)