Skip to content

Commit

Permalink
fix(fetc): Treat 'Some of the requested messages no longer exist' as …
Browse files Browse the repository at this point in the history
…a success, not a failure
  • Loading branch information
andris9 committed Nov 8, 2024
1 parent ff58b89 commit 565f988
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/imap-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,29 @@ class ImapFlow extends EventEmitter {
let err = new Error('Command failed');
err.response = parsed;
err.responseStatus = parsed.command.toUpperCase();

try {
err.executedCommand =
parsed.tag +
(
await compiler(request, {
isLogging: true
})
).toString();
} catch (err) {
// ignore
}

if (txt) {
err.responseText = txt;

if (err.responseStatus === 'NO' && txt.includes('Some of the requested messages no longer exist')) {
// Treat as successful response
this.log.warn({ msg: 'Partial Gmail response', cid: this.id, err });
await new Promise(resolve => request.resolve({ response: parsed, next: resolve }));
break;
}

let throttleDelay = false;

// MS365 throttling
Expand All @@ -596,7 +616,7 @@ class ImapFlow extends EventEmitter {
delayResponse = 5 * 60 * 1000;
}

this.log.warn({ msg: 'Throttling detected', err, cid: this.id, throttleDelay, delayResponse });
this.log.warn({ msg: 'Throttling detected', cid: this.id, throttleDelay, delayResponse, err });
await new Promise(r => setTimeout(r, delayResponse));
}
}
Expand Down

0 comments on commit 565f988

Please sign in to comment.