From b852feeb9cbb65b2072084bd38f628f5ac34d3df Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 9 Apr 2021 16:28:14 +0200 Subject: [PATCH] ConnectionError isn't throw from start, but sets sync.error --- src/matrix/SessionContainer.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/matrix/SessionContainer.js b/src/matrix/SessionContainer.js index 4e17e010..5191e745 100644 --- a/src/matrix/SessionContainer.js +++ b/src/matrix/SessionContainer.js @@ -234,19 +234,18 @@ export class SessionContainer { } async _waitForFirstSync() { - try { - this._sync.start(); - this._status.set(LoadStatus.FirstSync); - } catch (err) { - // swallow ConnectionError here and continue, - // as the reconnector above will call - // sync.start again to retry in this case - if (!(err instanceof ConnectionError)) { - throw err; - } - } + this._sync.start(); + this._status.set(LoadStatus.FirstSync); // only transition into Ready once the first sync has succeeded - this._waitForFirstSyncHandle = this._sync.status.waitFor(s => s === SyncStatus.Syncing || s === SyncStatus.Stopped); + this._waitForFirstSyncHandle = this._sync.status.waitFor(s => { + if (s === SyncStatus.Stopped) { + // keep waiting if there is a ConnectionError + // as the reconnector above will call + // sync.start again to retry in this case + return this._sync.error.name !== "ConnectionError"; + } + return s === SyncStatus.Syncing; + }); try { await this._waitForFirstSyncHandle.promise; if (this._sync.status.get() === SyncStatus.Stopped) {