Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Unable to restore session" on upgrade to element-web built on matrix-sdk-crypto-wasm 3.6.0 #26837

Closed
richvdh opened this issue Jan 8, 2024 · 14 comments
Labels
A-Element-R Issues affecting the port of Element's crypto layer to Rust O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Critical Prevents work, causes data loss and/or has no workaround Z-Labs

Comments

@richvdh
Copy link
Member

richvdh commented Jan 8, 2024

When @andybalaam upgraded to a version of element-web which included matrix-org/matrix-js-sdk#3989, he got the following:

image

We rolled back the update (matrix-org/matrix-js-sdk#3991) which solved the problem.

The logs include lines like:

2024-01-08T15:59:21.981Z E Unable to load session Error: invalid type: boolean `false`, expected u8

Closer inspection reveals that his indexeddb includes rows in inbound_group_sessions2 with needs_backup: false. This should never happen: needs_backup should be either 1 or absent. (If it were false, then (a) it should be serialized as 0 (b) it should be omitted altogether anyway, due to serialize_bool_for_indexeddb and skip_serializing_if = "std::ops::Not::not" respectively).

So the question is: how did these rows end up like this, and does it affect anyone except @andybalaam?

@richvdh richvdh added the A-Element-R Issues affecting the port of Element's crypto layer to Rust label Jan 8, 2024
@github-actions github-actions bot added the Z-Labs label Jan 8, 2024
@florianduros
Copy link
Member

I had the issue yesterday too. I can share a RS if needed.

@andybalaam
Copy link
Member

Yes please @florianduros , and could you also manually inspect your indexeddb? In the indexeddb table inbound_group_sessions2 I see some entries that say needs_backup:false:

image

which should never happen (it should always be either needs_backup:1 or no needs_backup key at all)

@florianduros
Copy link
Member

florianduros commented Jan 9, 2024

The RS (in zip to make github accep it) rageshake.tar.zip

@andybalaam I don't see any needs_backup entry in my indexeddb table

@andybalaam
Copy link
Member

andybalaam commented Jan 9, 2024

I'm getting a lot of

[PerSessionKeyBackupDownloader] Error while decrypting and importing key backup for session eccmiLkh0tFIGZcktq5paapCTlvSbm3D7OEBCDftGG0 TypeError: `target` argument of Reflect.get must be an object, got "2kZss1clJ1hfJprn/lL4J4UCxqv+heQih0O1ESOHwj0"
  • probably unrelated, but just in case.

@andybalaam
Copy link
Member

andybalaam commented Jan 9, 2024

From Florian's rageshake:

2024-01-08T17:52:08.801Z E Unable to load session DomException VersionError (0): The operation failed because the stored database is a higher version than the version requested.
./matrix-js-sdk/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm.js/module.exports.__wbindgen_error_new@https://develop.element.io/bundles/537c779b539e5b6ce39f/6984.js:7291:17
<T as futures_util::fns::FnOnce1<A>>::call_once::h08865017a8c6822a@https://develop.element.io/bundles/537c779b539e5b6ce39f/6984.js line 8410 > WebAssembly.instantiate:wasm-function[5204]:0x336c71
matrix_sdk_crypto_wasm::future::future_to_promise_with_custom_error::{{closure}}::{{closure}}::h6470b98ef1be1fb0@https://develop.element.io/bundles/537c779b539e5b6ce39f/6984.js line 8410 > WebAssembly.instantiate:wasm-function[1282]:0x210463
wasm_bindgen_futures::queue::Queue::new::{{closure}}::h2a3a1fb83cacd363@https://develop.element.io/bundles/537c779b539e5b6ce39f/6984.js line 8410 > WebAssembly.instantiate:wasm-function[1241]:0x20740c
<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h8cef6383e8d1f614@https://develop.element.io/bundles/537c779b539e5b6ce39f/6984.js line 8410 > WebAssembly.instantiate:wasm-function[7701]:0x36c642
__wbg_adapter_63@https://develop.element.io/bundles/537c779b539e5b6ce39f/6984.js:293:10
real@https://develop.element.io/bundles/537c779b539e5b6ce39f/6984.js:235:20

So my first guess is that Florian is not seeing the problem I saw. Instead, he successfully upgraded to version 8 of inbound_groups_sessions2 and now the code is upset because the version is higher than expected after we reverted.

@andybalaam
Copy link
Member

@florianduros please can you confirm that you have an 8 here?:

image

@andybalaam
Copy link
Member

If I'm right about what happened to @florianduros , it will be still broken for him. Meanwhile, it was unbroken for me by the revert we merged.

@florianduros
Copy link
Member

@andybalaam no, I have a 7.

Capture d’écran 2024-01-09 à 15 54 47

@andybalaam
Copy link
Member

And is it unbroken now @florianduros ? (Because we reverted the change, so it should not attempt an upgrade to v8)

@florianduros
Copy link
Member

florianduros commented Jan 9, 2024

@andybalaam When it happened, I clicked on Clear storage and sign out and signed in again. It fixed the issue to me to sign out and sign in

@andybalaam
Copy link
Member

@andybalaam When it happened, I clicked on Clear storage and sign out and signed in again. It fixed the issue to me to sign out and sign in

Ah, then I think my original theory is right: you upgraded to version 8, and that went wrong when we reverted the code making it expect version 7. When you cleared storage, the code recreated it at version 7.

@dbkr dbkr added S-Critical Prevents work, causes data loss and/or has no workaround O-Uncommon Most users are unlikely to come across this or unexpected workflow labels Jan 9, 2024
@lieuwex
Copy link

lieuwex commented Jan 9, 2024

rageshake (2).zip

I got the same issue, but weirdly enough not yesterday but today.

@andybalaam
Copy link
Member

From @lieuwex 's rageshake:

2024-01-09T18:03:13.714Z E Unable to load session DomException VersionError (0): The requested version (7) is less than the existing version (8).
Error: DomException VersionError (0): The requested version (7) is less than the existing version (8).

Again, this is caused by the revert, not the original problem.

@andybalaam
Copy link
Member

After looking through my local Firefox console logs, I discovered a snippet of code I ran (and forgot!) that modified my indexeddb, setting needs_backup to false manually.

That was the cause of this problem, and I am sorry for the noise. I opened matrix-org/matrix-js-sdk#4001 to re-apply the upgrade, which should fix the problem found by @florianduros and @lieuwex when it is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Element-R Issues affecting the port of Element's crypto layer to Rust O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Critical Prevents work, causes data loss and/or has no workaround Z-Labs
Projects
None yet
Development

No branches or pull requests

5 participants