Split the "Too many requests" error in ping service

issue https://github.com/TryGhost/Team/issues/362
This commit is contained in:
Thibaut Patel 2021-02-16 15:31:44 +01:00 committed by naz
parent ac1bfe93b8
commit 58be6d23db
2 changed files with 30 additions and 6 deletions

View File

@ -82,12 +82,21 @@ function ping(post) {
}
})
.catch(function (err) {
if (err.statusCode === 429) {
logging.error(new errors.TooManyRequestsError({
err,
message: err.message,
context: i18n.t('errors.services.ping.requestFailed.error', {service: 'xmlrpc'}),
help: i18n.t('errors.services.ping.requestFailed.help', {url: 'https://ghost.org/docs/'})
}));
} else {
logging.error(new errors.GhostError({
err: err,
message: err.message,
context: i18n.t('errors.services.ping.requestFailed.error', {service: 'xmlrpc'}),
help: i18n.t('errors.services.ping.requestFailed.help', {url: 'https://ghost.org/docs/'})
}));
}
});
});
}

View File

@ -255,5 +255,20 @@ describe('XMLRPC', function () {
setTimeout(retry, 100);
}());
});
it('should behave correctly when getting a 429', function (done) {
const ping1 = nock('http://rpc.pingomatic.com').post('/').reply(429);
const testPost = _.clone(testUtils.DataGenerator.Content.posts[2]);
ping(testPost);
(function retry() {
if (ping1.isDone()) {
return done();
}
setTimeout(retry, 100);
}());
});
});
});