mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-11 02:30:21 +08:00
[client-sync] Ensure we use refreshed access token for mail listener conn
Summary: Before this commit, we would just establish a single mail listener imap connection and never check if we needed to re-connect it due to an expired access token. Even though we correctly refreshed the access token at the beggining of each sync loop (hidden under `ensureSMTPConnection`), we would never re-establish the mail listener connection with the new access token. This would cause the app to enter an `Invalid Credentials` error loop in the sync loop, preventing from syncing any mail at all (T8064) Test Plan: manual Reviewers: spang, halla, mark, evan Reviewed By: mark, evan Differential Revision: https://phab.nylas.com/D4338
This commit is contained in:
parent
7dec807b28
commit
a461490e41
1 changed files with 6 additions and 6 deletions
|
@ -229,9 +229,8 @@ class SyncWorker {
|
|||
}
|
||||
}
|
||||
|
||||
async _ensureSMTPConnection() {
|
||||
async _ensureSMTPConnection(newCredentials) {
|
||||
if (this._destroyed) { return }
|
||||
const newCredentials = await this._ensureAccessToken();
|
||||
if (!this._smtp || newCredentials) {
|
||||
this._smtp = new SendmailClient(this._account, this._logger)
|
||||
}
|
||||
|
@ -249,9 +248,9 @@ class SyncWorker {
|
|||
this._conn._db = this._db;
|
||||
}
|
||||
|
||||
async _ensureIMAPMailListenerConnection() {
|
||||
async _ensureIMAPMailListenerConnection(newCredentials) {
|
||||
if (this._destroyed) { return }
|
||||
if (this._mailListenerConn) {
|
||||
if (!newCredentials && this._mailListenerConn) {
|
||||
await this._mailListenerConn.connect();
|
||||
return
|
||||
}
|
||||
|
@ -579,8 +578,9 @@ class SyncWorker {
|
|||
this._logger.log(`🔃 🆕 Reason: ${reason}`)
|
||||
let error;
|
||||
try {
|
||||
await this._ensureSMTPConnection();
|
||||
await this._ensureIMAPMailListenerConnection();
|
||||
const newCredentials = await this._ensureAccessToken()
|
||||
await this._ensureSMTPConnection(newCredentials);
|
||||
await this._ensureIMAPMailListenerConnection(newCredentials);
|
||||
await IMAPConnectionPool.withConnectionsForAccount(this._account, {
|
||||
desiredCount: 1,
|
||||
logger: this._logger,
|
||||
|
|
Loading…
Reference in a new issue