Open richvdh opened 1 year ago
This is back
There is a test that is supposed to catch this (MatrixClient.clearStores > should clear the indexeddbs
in matrix-js-sdk/spec/integ/crypto/rust-crypto.spec.ts
). Once we find the leak, we should extend the test to reproduce the problem area.
I now can't reproduce this.
We're still seeing this intermittently
The root cause here is failures to clean up objects on the rust side during logout, which means we end up holding onto a connection to the IndexedDB. That means that we can't delete the IndexedDB, and when we log in again, attempts to open the IndexedDB block indefinitely.
The reason that the Rust objects aren't being cleaned up is that we're relying on javascript's FinalizationRegistry
to call the rust-side destructors. As the MDN page makes clear, that mechanism is unreliable.
We could attempt to explicitly call .free
on every reference to a Rust object that is ever passed to the JS layer (as we did for a specific case with https://github.com/matrix-org/matrix-js-sdk/pull/3610), but that is likely to add a lot of boilerplate, and be very brittle.
A more plausible solution is to update the matrix-rust-sdk IndexeddbCryptoStore
so that it doesn't maintain a connection to the Indexeddb throughout its lifetime, but rather opens a new one each time an operation is performed. Opening the Indexeddb is quick enough that this shouldn't have a significant performance impact.
Sometimes, when attempting to log in, you get faced with a spinner of doom:
I think it's something indexedDB related. From the logs:
note
cannot yet remove IndexedDB instance
in particular.It's fine after a reload.