From 33ef225d4bc15b08644f14bb8f5634c35cd49816 Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Tue, 5 Mar 2024 13:07:15 +0200 Subject: [PATCH] update --- lib/mailbox.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/mailbox.js b/lib/mailbox.js index d2cb9a59..ecfcaf7a 100644 --- a/lib/mailbox.js +++ b/lib/mailbox.js @@ -1746,6 +1746,12 @@ class Mailbox { } fetchCompleted = true; } catch (err) { + if (!imapClient.usable) { + // nothing to do here, connection closed + this.logger.error({ msg: `FETCH failed, connection already closed, not retrying` }); + return; + } + try { // set failure flag await this.connection.redis.hSetExists( @@ -1766,12 +1772,6 @@ class Mailbox { } // retry - if (!imapClient.usable) { - // nothing to do here, connection closed - this.logger.error({ msg: `FETCH failed, connection already closed, not retrying` }); - return; - } - let fetchRetryDelay = calculateFetchBackoff(++fetchRetryCount); this.logger.error({ msg: `FETCH failed, retrying in ${Math.round(fetchRetryDelay / 1000)}s` }); await new Promise(r => setTimeout(r, fetchRetryDelay));