mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-13 01:17:27 +03:00
Responded with 409 when we have DB conflicts
refs https://github.com/TryGhost/Team/issues/789 We are still having issues with duplicate subscriptions being inserted, despite running our code in transactions. For now we will catch these errors and response ot Stripe with a 409 so that it'll retry later - and it stops us from throwing 500's
This commit is contained in:
parent
80a0e56d36
commit
c99ebe589d
@ -134,7 +134,17 @@ module.exports = class StripeWebhookService {
|
||||
return;
|
||||
}
|
||||
|
||||
await this[this.handlers[event.type]](event.data.object);
|
||||
try {
|
||||
await this[this.handlers[event.type]](event.data.object);
|
||||
} catch (err) {
|
||||
if (err.code !== 'ER_DUP_ENTRY' && err.code !== 'SQLITE_CONSTRAINT') {
|
||||
throw err;
|
||||
}
|
||||
throw new errors.GhostError({
|
||||
err,
|
||||
statusCode: 409
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async subscriptionEvent(subscription) {
|
||||
|
Loading…
Reference in New Issue
Block a user