diff --git a/packages/isomorphic-core/src/imap-connection.es6 b/packages/isomorphic-core/src/imap-connection.es6 index d36a86100..b2fbe5926 100644 --- a/packages/isomorphic-core/src/imap-connection.es6 +++ b/packages/isomorphic-core/src/imap-connection.es6 @@ -268,6 +268,13 @@ class IMAPConnection extends EventEmitter { return this._imap.serverSupports(capability); } + getLastOpenDuration() { + if (this._isOpeningBox) { + throw new RetryableError('IMAPConnection: Cannot operate on connection while opening a box.') + } + return this._lastOpenDuration; + } + /** * @return {Promise} that resolves to instance of IMAPBox */ @@ -281,9 +288,9 @@ class IMAPConnection extends EventEmitter { if (!refetchBoxInfo && folderName === this.getOpenBoxName()) { return Promise.resolve(new IMAPBox(this, this._imap._box)); } - this._isOpeningBox = true - this._lastOpenDuration = null; return this._withPreparedConnection(async (imap) => { + this._isOpeningBox = true + this._lastOpenDuration = null; const before = Date.now(); const box = await imap.openBoxAsync(folderName, readOnly) this._lastOpenDuration = Date.now() - before; @@ -292,13 +299,6 @@ class IMAPConnection extends EventEmitter { }) } - getLastOpenDuration() { - if (this._isOpeningBox) { - throw new RetryableError('IMAPConnection: Cannot operate on connection while opening a box.') - } - return this._lastOpenDuration; - } - async getLatestBoxStatus(folderName) { if (!folderName) { throw new Error('IMAPConnection::getLatestBoxStatus - You must provide a folder name')