|
|
@@ -36,6 +36,7 @@ import {
|
|
|
TransitionPaymentToStateResult,
|
|
|
UpdateOrderNoteInput,
|
|
|
} from '@vendure/common/lib/generated-types';
|
|
|
+import { omit } from '@vendure/common/lib/omit';
|
|
|
import { ID, PaginatedList } from '@vendure/common/lib/shared-types';
|
|
|
import { summate } from '@vendure/common/lib/shared-utils';
|
|
|
import { In, IsNull } from 'typeorm';
|
|
|
@@ -1694,7 +1695,12 @@ export class OrderService {
|
|
|
promotions,
|
|
|
updatedOrderLines ?? [],
|
|
|
);
|
|
|
- await this.connection.getRepository(ctx, Order).save(updatedOrder, { reload: false });
|
|
|
+ await this.connection
|
|
|
+ .getRepository(ctx, Order)
|
|
|
+ // Explicitly omit the shippingAddress and billingAddress properties to avoid
|
|
|
+ // a race condition where changing one or the other in parallel can
|
|
|
+ // overwrite the other's changes.
|
|
|
+ .save(omit(updatedOrder, ['shippingAddress', 'billingAddress']), { reload: false });
|
|
|
await this.connection.getRepository(ctx, OrderLine).save(updatedOrder.lines, { reload: false });
|
|
|
await this.connection.getRepository(ctx, ShippingLine).save(order.shippingLines, { reload: false });
|
|
|
await this.promotionService.runPromotionSideEffects(ctx, order, activePromotionsPre);
|