From f4b83e1a277c25c8cb894b0739b0dec87d8c208d Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 9 Mar 2023 10:51:19 +0000 Subject: [PATCH] Stop a failed `/keys/claim` request getting stuck Putting the new request inside a `finally` block meant we would never actually transition the promise chain from failure to success. Sticking a no-op `catch` in the chain makes sure that we can recover from an error. --- src/rust-crypto/KeyClaimManager.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rust-crypto/KeyClaimManager.ts b/src/rust-crypto/KeyClaimManager.ts index 0479bfa43..9df8f89da 100644 --- a/src/rust-crypto/KeyClaimManager.ts +++ b/src/rust-crypto/KeyClaimManager.ts @@ -54,7 +54,12 @@ export class KeyClaimManager { // The Rust-SDK requires that we only have one getMissingSessions process in flight at once. This little dance // ensures that, by only having one call to ensureSessionsForUsersInner active at once (and making them // queue up in order). - const prom = this.currentClaimPromise.finally(() => this.ensureSessionsForUsersInner(userList)); + const prom = this.currentClaimPromise + .catch(() => { + // any errors in the previous claim will have been reported already, so there is nothing to do here. + // we just throw away the error and start anew. + }) + .then(() => this.ensureSessionsForUsersInner(userList)); this.currentClaimPromise = prom; return prom; }