Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 3a09c22

Browse files
authored
Merge pull request #5812 from matrix-org/jryans/cancel-security-key
Tweak security key error handling
2 parents 5df4ad2 + 02548cf commit 3a09c22

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

src/SecurityManager.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ export async function accessSecretStorage(func = async () => { }, forceReset = f
395395
} catch (e) {
396396
SecurityCustomisations.catchAccessSecretStorageError?.(e);
397397
console.error(e);
398+
// Re-throw so that higher level logic can abort as needed
399+
throw e;
398400
} finally {
399401
// Clear secret storage key cache now that work is complete
400402
secretStorageBeingAccessed = false;

src/stores/SetupEncryptionStore.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,16 @@ export class SetupEncryptionStore extends EventEmitter {
121121
// on the first trust check, and the key backup restore will happen
122122
// in the background.
123123
await new Promise((resolve, reject) => {
124-
try {
125-
accessSecretStorage(async () => {
126-
await cli.checkOwnCrossSigningTrust();
127-
resolve();
128-
if (backupInfo) {
129-
// A complete restore can take many minutes for large
130-
// accounts / slow servers, so we allow the dialog
131-
// to advance before this.
132-
await cli.restoreKeyBackupWithSecretStorage(backupInfo);
133-
}
134-
}).catch(reject);
135-
} catch (e) {
136-
console.error(e);
137-
reject(e);
138-
}
124+
accessSecretStorage(async () => {
125+
await cli.checkOwnCrossSigningTrust();
126+
resolve();
127+
if (backupInfo) {
128+
// A complete restore can take many minutes for large
129+
// accounts / slow servers, so we allow the dialog
130+
// to advance before this.
131+
await cli.restoreKeyBackupWithSecretStorage(backupInfo);
132+
}
133+
}).catch(reject);
139134
});
140135

141136
if (cli.getCrossSigningId()) {

0 commit comments

Comments
 (0)