mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 05:14:12 +03:00
Fixed race condition when linking subscriptions
no-issue Without forcing linkSubscription to run inside a transaction - it's possible to have race conditions where it is called twice, and attempt to insert duplicate rows into the database.
This commit is contained in:
parent
c58e83c9d7
commit
8051015bb8
@ -519,6 +519,15 @@ module.exports = class MemberRepository {
|
||||
if (!this._stripeAPIService.configured) {
|
||||
throw new errors.BadRequestError(tpl(messages.noStripeConnection, {action: 'link Stripe Subscription'}));
|
||||
}
|
||||
|
||||
if (!options.transacting) {
|
||||
return this._Member.transaction((transacting) => {
|
||||
return this.linkSubscription(data, {
|
||||
...options,
|
||||
transacting
|
||||
});
|
||||
});
|
||||
}
|
||||
const member = await this._Member.findOne({
|
||||
id: data.id
|
||||
}, options);
|
||||
|
Loading…
Reference in New Issue
Block a user