[iso-core] Fix imap error detection!

Summary:
We were only detecting and classifying IMAP errors as retryable and non
retryable in a few places, but errors thrown in any of our imap
operations were not being properly passed through our `convertImapErrors` :(

This was broken, oh so broken

Also loosen condition to detect System Errors

Test Plan: manual

Reviewers: spang, mark, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4022
This commit is contained in:
Juan Tejada 2017-02-22 14:17:52 -08:00
parent feda238d9c
commit b96300f000
2 changed files with 6 additions and 2 deletions

View file

@ -346,7 +346,11 @@ class IMAPConnection extends EventEmitter {
clearTimeout(socketTimeout)
resolve(...args)
}
return callback(cbResolve, reject)
const cbReject = (error) => {
clearTimeout(socketTimeout)
reject(convertImapError(error))
}
return callback(cbResolve, cbReject)
})
.finally(() => {
if (this._imap) {

View file

@ -82,7 +82,7 @@ function convertImapError(imapError) {
error.source = imapError.source
return error
}
if (imapError.message.includes('System Error')) {
if (/system error/i.test(imapError.message)) {
// System Errors encountered in the wild so far have been retryable.
error = new RetryableError(imapError)
error.source = imapError.source