From 09589173179a71f1b269e8aa61eb994bff718f42 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 21 Apr 2020 14:28:10 +0100 Subject: [PATCH] Make getAccountDataFromServer return null if not found Callers assume that if the account data isn't there, the method will return null rather than throw an exception. This meant that this only actually worked in these cases when the sync had completed and it was using the locally stored account data, so this ceased to be a problem in practice when we made it wait for the initial sync to finish before entering the security setup flow. Fixes https://github.com/vector-im/riot-web/issues/13169 --- src/client.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/client.js b/src/client.js index 8dc6cc19e..b9b3203bd 100644 --- a/src/client.js +++ b/src/client.js @@ -2135,9 +2135,17 @@ MatrixClient.prototype.getAccountDataFromServer = async function(eventType) { $userId: this.credentials.userId, $type: eventType, }); - return this._http.authedRequest( - undefined, "GET", path, undefined, - ); + try { + const result = await this._http.authedRequest( + undefined, "GET", path, undefined, + ); + return result; + } catch (e) { + if (e.data && e.data.errcode === 'M_NOT_FOUND') { + return null; + } + throw e; + } }; /**