mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 03:14:03 +03:00
Added catch to unhandled promises rejections (#15994)
refs https://github.com/TryGhost/Team/issues/2370 Reduces amount of unhandled promise rejections
This commit is contained in:
parent
3bd5dd66e0
commit
237d4d53d4
@ -571,19 +571,25 @@ async function createEmailBatches({emailModel, memberRows, memberSegment, option
|
||||
return batchIds;
|
||||
}
|
||||
|
||||
const statusChangedHandler = (emailModel, options) => {
|
||||
const statusChangedHandler = async (emailModel, options) => {
|
||||
const emailRetried = emailModel.wasChanged()
|
||||
&& emailModel.get('status') === 'pending'
|
||||
&& emailModel.previous('status') === 'failed';
|
||||
|
||||
if (emailRetried) {
|
||||
pendingEmailHandler(emailModel, options);
|
||||
await pendingEmailHandler(emailModel, options);
|
||||
}
|
||||
};
|
||||
|
||||
function listen() {
|
||||
events.on('email.added', pendingEmailHandler);
|
||||
events.on('email.edited', statusChangedHandler);
|
||||
events.on('email.added', (emailModel, options) => pendingEmailHandler(emailModel, options).catch((e) => {
|
||||
logging.error('Error in email.added event handler');
|
||||
logging.error(e);
|
||||
}));
|
||||
events.on('email.edited', (emailModel, options) => statusChangedHandler(emailModel, options).catch((e) => {
|
||||
logging.error('Error in email.edited event handler');
|
||||
logging.error(e);
|
||||
}));
|
||||
}
|
||||
|
||||
// Public API
|
||||
|
@ -22,7 +22,9 @@ async function configureApi() {
|
||||
}
|
||||
|
||||
const debouncedConfigureApi = _.debounce(() => {
|
||||
configureApi();
|
||||
configureApi().catch((err) => {
|
||||
logging.error(err);
|
||||
});
|
||||
}, 600);
|
||||
|
||||
module.exports = new StripeService({
|
||||
|
Loading…
Reference in New Issue
Block a user