From b8b198125de945c5a9a0751a106ae4da511e2e7b Mon Sep 17 00:00:00 2001 From: ClaraCrazy Date: Thu, 8 Jan 2026 11:06:45 +0100 Subject: [PATCH] [Fix]: Large purge failures I swear writing a tempmail service is hard --- application/imap-service.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/application/imap-service.js b/application/imap-service.js index 16a0d39..e6dc181 100644 --- a/application/imap-service.js +++ b/application/imap-service.js @@ -296,11 +296,15 @@ class ImapService extends EventEmitter { } debug(`Deleting mails ${toDelete}`); - await this.connection.deleteMessage(toDelete); - - toDelete.forEach(uid => { - this.emit(ImapService.EVENT_DELETED_MAIL, uid); - }); + // Batch deletes to avoid IMAP argument limits + const BATCH_SIZE = 100; + for (let i = 0; i < toDelete.length; i += BATCH_SIZE) { + const batch = toDelete.slice(i, i + BATCH_SIZE); + await this.connection.deleteMessage(batch); + batch.forEach(uid => { + this.emit(ImapService.EVENT_DELETED_MAIL, uid); + }); + } }