From c02928f29486c3ede85d6565921faed3abb1162c Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 9 Mar 2020 15:08:12 +0000 Subject: [PATCH] Upload cross-signing key signatures in the background At the moment, uploading cross-signing key signatures is a slow process that can potentially take many minutes (!) for large accounts / slow servers. This changes to do the bootstrapping related versions of this in the background. Note that key signature uploads for interactive flows like verification are still blocking for now. Fixes https://github.com/vector-im/riot-web/issues/12223 --- src/crypto/index.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/crypto/index.js b/src/crypto/index.js index 37f638c31..fac954266 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -666,10 +666,15 @@ Crypto.prototype._afterCrossSigningLocalKeyChange = async function() { // sign the current device with the new key, and upload to the server const device = this._deviceList.getStoredDevice(this._userId, this._deviceId); const signedDevice = await this._crossSigningInfo.signDevice(this._userId, device); - await this._baseApis.uploadKeySignatures({ + logger.info(`Starting background key sig upload for ${this._deviceId}`); + this._baseApis.uploadKeySignatures({ [this._userId]: { [this._deviceId]: signedDevice, }, + }).then(() => { + logger.info(`Finished background key sig upload for ${this._deviceId}`); + }).catch(e => { + logger.error(`Error during background key sig upload for ${this._deviceId}`, e); }); const shouldUpgradeCb = ( @@ -952,8 +957,14 @@ Crypto.prototype.checkOwnCrossSigningTrust = async function() { = this._crossSigningInfo.keys.master; } - if (Object.keys(keySignatures).length) { - await this._baseApis.uploadKeySignatures({[this._userId]: keySignatures}); + const keysToUpload = Object.keys(keySignatures); + if (keysToUpload.length) { + logger.info(`Starting background key sig upload for ${keysToUpload}`); + this._baseApis.uploadKeySignatures({ [this._userId]: keySignatures }).then(() => { + logger.info(`Finished background key sig upload for ${keysToUpload}`); + }).catch(e => { + logger.error(`Error during background key sig upload for ${keysToUpload}`, e); + }); } this.emit("userTrustStatusChanged", userId, this.checkUserTrust(userId));