mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-27 18:52:14 +03:00
Split the "Too many requests" error in ping service
issue https://github.com/TryGhost/Team/issues/362
This commit is contained in:
parent
ac1bfe93b8
commit
58be6d23db
@ -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/'})
|
||||
}));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -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);
|
||||
}());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user