cloudflare: Fix crash when there is an external error updating dns records

This commit is contained in:
Girish Ramakrishnan
2018-09-06 12:26:11 -07:00
parent 5e919b90f5
commit df66d77a68
3 changed files with 10 additions and 5 deletions

View File

@@ -625,7 +625,7 @@ function txtRecordsWithSpf(domain, callback) {
assert.strictEqual(typeof callback, 'function');
domains.getDnsRecords('', domain, 'TXT', function (error, txtRecords) {
if (error) return callback(error);
if (error) return new MailError(MailError.EXTERNAL_ERROR, error.message);
debug('txtRecordsWithSpf: current txt records - %j', txtRecords);
@@ -741,10 +741,14 @@ function setDnsRecords(domain, callback) {
async.mapSeries(records, function (record, iteratorCallback) {
domains.upsertDnsRecords(record.subdomain, record.domain, record.type, record.values, iteratorCallback);
}, function (error, changeIds) {
if (error) debug('addDnsRecords: failed to update : %s. will retry', error);
else debug('addDnsRecords: records %j added with changeIds %j', records, changeIds);
if (error) {
debug(`addDnsRecords: failed to update: ${error}`);
return callback(new MailError(MailError.EXTERNAL_ERROR, error.message));
}
callback(error);
debug('addDnsRecords: records %j added with changeIds %j', records, changeIds);
callback(null);
});
});
});