From f1683d717a6ccb8ea6155dfc34c5ffc43a2fb798 Mon Sep 17 00:00:00 2001 From: greta Date: Mon, 8 Sep 2025 12:45:20 +0200 Subject: [PATCH 1/4] fix: endless burst of requests on uncached mailboxes Signed-off-by: greta --- src/components/Mailbox.vue | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/Mailbox.vue b/src/components/Mailbox.vue index ab52b9b919..ebd57ce9b8 100644 --- a/src/components/Mailbox.vue +++ b/src/components/Mailbox.vue @@ -201,17 +201,21 @@ export default { this.stopInterval() }, methods: { - initializeCache() { + async initializeCache() { this.loadingCacheInitialization = true this.error = false - logger.debug(`syncing folder ${this.mailbox.databaseId} (${this.query}) during cache initalization`) - this.sync(true) - .then(() => { - this.loadingCacheInitialization = false - - return this.loadEnvelopes() - }) + logger.debug(`syncing folder ${this.mailbox.databaseId} (${this.query}) during cache initialization`) + try { + await this.sync(true) + await wait(5000) + await this.loadEnvelopes() + } catch (error) { + logger.error(`Could not initialize cache of folder ${this.mailbox.databaseId} (${this.searchQuery})`, { error }) + this.error = error + } finally { + this.loadingCacheInitialization = false + } }, async loadEnvelopes() { logger.debug(`Fetching envelopes for folder ${this.mailbox.databaseId} (${this.searchQuery})`, this.mailbox) From 3c6fba122586b6e1c6d564bf05dd91ca20147fbf Mon Sep 17 00:00:00 2001 From: greta Date: Mon, 8 Sep 2025 16:57:25 +0200 Subject: [PATCH 2/4] fixup! fix: endless burst of requests on uncached mailboxes Signed-off-by: greta --- src/components/Mailbox.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Mailbox.vue b/src/components/Mailbox.vue index ebd57ce9b8..916c918b89 100644 --- a/src/components/Mailbox.vue +++ b/src/components/Mailbox.vue @@ -208,7 +208,6 @@ export default { logger.debug(`syncing folder ${this.mailbox.databaseId} (${this.query}) during cache initialization`) try { await this.sync(true) - await wait(5000) await this.loadEnvelopes() } catch (error) { logger.error(`Could not initialize cache of folder ${this.mailbox.databaseId} (${this.searchQuery})`, { error }) From 72c45461ae212f048847fb787982ea0eef036939 Mon Sep 17 00:00:00 2001 From: greta Date: Fri, 19 Sep 2025 14:53:30 +0200 Subject: [PATCH 3/4] fixup! fix: endless burst of requests on uncached mailboxes Signed-off-by: greta --- src/components/Mailbox.vue | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/components/Mailbox.vue b/src/components/Mailbox.vue index 916c918b89..98ea2c3f03 100644 --- a/src/components/Mailbox.vue +++ b/src/components/Mailbox.vue @@ -217,7 +217,14 @@ export default { } }, async loadEnvelopes() { + // Dont fetch if cache initialization is in progress + if (this.loadingCacheInitialization) { + logger.debug('Cache initialization in progress, skipping envelope fetch') + return + } + logger.debug(`Fetching envelopes for folder ${this.mailbox.databaseId} (${this.searchQuery})`, this.mailbox) + if (!this.syncedMailboxes.has(this.mailbox.databaseId)) { // Only trigger skeleton if we didn't sync envelopes yet this.loadingEnvelopes = true @@ -227,7 +234,6 @@ export default { this.skipListTransition = false }) } - this.loadingCacheInitialization = false this.error = false @@ -237,28 +243,35 @@ export default { query: this.searchQuery, limit: this.initialPageSize, }) - logger.debug(envelopes.length + ' envelopes fetched', { envelopes }) - this.syncedMailboxes.add(this.mailbox.databaseId) this.loadingEnvelopes = false } catch (error) { await matchError(error, { [MailboxLockedError.getName()]: async (error) => { - logger.info(`Mailbox ${this.mailbox.databaseId} (${this.searchQuery}) is locked`, { error }) + logger.info(`Mailbox ${this.mailbox.databaseId} (${this.searchQuery}) is locked, retrying after delay`, { error }) await wait(15 * 1000) - // Keep trying + // Only retry if mailbox is locked await this.loadEnvelopes() }, [MailboxNotCachedError.getName()]: async (error) => { - logger.info(`Mailbox ${this.mailbox.databaseId} (${this.searchQuery}) not cached. Triggering initialization`, { error }) + logger.info(`Mailbox ${this.mailbox.databaseId} (${this.searchQuery}) not cached. Triggering initialization.`, { error }) this.loadingEnvelopes = false + if (this.loadingCacheInitialization) { + logger.debug('Cache initialization already in progress, skipping additional initialization.') + return + } + + this.loadingCacheInitialization = true try { await this.initializeCache() + await this.loadEnvelopes() } catch (error) { logger.error(`Could not initialize cache of folder ${this.mailbox.databaseId} (${this.searchQuery})`, { error }) this.error = error + } finally { + this.loadingCacheInitialization = false } }, default: (error) => { From c1909028401780012c4a85b2df52404e9e7a0362 Mon Sep 17 00:00:00 2001 From: greta Date: Fri, 19 Sep 2025 15:06:35 +0200 Subject: [PATCH 4/4] fixup! fix: endless burst of requests on uncached mailboxes Signed-off-by: greta --- src/components/Mailbox.vue | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/components/Mailbox.vue b/src/components/Mailbox.vue index 98ea2c3f03..eaf6d6f58c 100644 --- a/src/components/Mailbox.vue +++ b/src/components/Mailbox.vue @@ -202,6 +202,10 @@ export default { }, methods: { async initializeCache() { + if (this.loadingCacheInitialization) { + logger.debug('Cache initialization in progress, skipping envelope fetch') + return + } this.loadingCacheInitialization = true this.error = false @@ -217,14 +221,7 @@ export default { } }, async loadEnvelopes() { - // Dont fetch if cache initialization is in progress - if (this.loadingCacheInitialization) { - logger.debug('Cache initialization in progress, skipping envelope fetch') - return - } - logger.debug(`Fetching envelopes for folder ${this.mailbox.databaseId} (${this.searchQuery})`, this.mailbox) - if (!this.syncedMailboxes.has(this.mailbox.databaseId)) { // Only trigger skeleton if we didn't sync envelopes yet this.loadingEnvelopes = true @@ -234,6 +231,7 @@ export default { this.skipListTransition = false }) } + this.loadingCacheInitialization = false this.error = false @@ -243,35 +241,28 @@ export default { query: this.searchQuery, limit: this.initialPageSize, }) + logger.debug(envelopes.length + ' envelopes fetched', { envelopes }) + this.syncedMailboxes.add(this.mailbox.databaseId) this.loadingEnvelopes = false } catch (error) { await matchError(error, { [MailboxLockedError.getName()]: async (error) => { - logger.info(`Mailbox ${this.mailbox.databaseId} (${this.searchQuery}) is locked, retrying after delay`, { error }) + logger.info(`Mailbox ${this.mailbox.databaseId} (${this.searchQuery}) is locked`, { error }) await wait(15 * 1000) - // Only retry if mailbox is locked + // Keep trying await this.loadEnvelopes() }, [MailboxNotCachedError.getName()]: async (error) => { - logger.info(`Mailbox ${this.mailbox.databaseId} (${this.searchQuery}) not cached. Triggering initialization.`, { error }) + logger.info(`Mailbox ${this.mailbox.databaseId} (${this.searchQuery}) not cached. Triggering initialization`, { error }) this.loadingEnvelopes = false - if (this.loadingCacheInitialization) { - logger.debug('Cache initialization already in progress, skipping additional initialization.') - return - } - - this.loadingCacheInitialization = true try { await this.initializeCache() - await this.loadEnvelopes() } catch (error) { logger.error(`Could not initialize cache of folder ${this.mailbox.databaseId} (${this.searchQuery})`, { error }) this.error = error - } finally { - this.loadingCacheInitialization = false } }, default: (error) => {