From 90ea88882978859595f4980efb71bfe54a8b4d33 Mon Sep 17 00:00:00 2001 From: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com> Date: Thu, 18 Feb 2021 13:46:34 +0100 Subject: [PATCH 1/2] hotfix(medusa-fulfillment-webshipper): Cancel fulfillment idempotently (#175) --- .../src/services/webshipper-fulfillment.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/medusa-fulfillment-webshipper/src/services/webshipper-fulfillment.js b/packages/medusa-fulfillment-webshipper/src/services/webshipper-fulfillment.js index 89142f3bb6..43d96fd573 100644 --- a/packages/medusa-fulfillment-webshipper/src/services/webshipper-fulfillment.js +++ b/packages/medusa-fulfillment-webshipper/src/services/webshipper-fulfillment.js @@ -523,6 +523,11 @@ class WebshipperFulfillmentService extends FulfillmentService { .retrieve(data.id) .catch(() => undefined) + // if order does not exist, we resolve gracefully + if (!order) { + return Promise.resolve() + } + if (order) { if (order.data.attributes.status !== "pending") { if (order.data.attributes.status === "cancelled") { From ba39cb16db88e24b1ebf9d5d62ca0c43609db4dd Mon Sep 17 00:00:00 2001 From: Sebastian Rindom Date: Wed, 24 Feb 2021 08:52:39 +0100 Subject: [PATCH 2/2] hotfix(brightpearl): wrap inventory update in transaction --- .../src/services/brightpearl.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/medusa-plugin-brightpearl/src/services/brightpearl.js b/packages/medusa-plugin-brightpearl/src/services/brightpearl.js index a114000e52..2fd27359e8 100644 --- a/packages/medusa-plugin-brightpearl/src/services/brightpearl.js +++ b/packages/medusa-plugin-brightpearl/src/services/brightpearl.js @@ -5,6 +5,7 @@ import Brightpearl from "../utils/brightpearl" class BrightpearlService extends BaseService { constructor( { + manager, oauthService, totalsService, productVariantService, @@ -18,6 +19,7 @@ class BrightpearlService extends BaseService { ) { super() + this.manager_ = manager this.options = options this.productVariantService_ = productVariantService this.regionService_ = regionService @@ -189,8 +191,12 @@ class BrightpearlService extends BaseService { .retrieveBySKU(sku) .catch((_) => undefined) if (variant && variant.manage_inventory) { - await this.productVariantService_.update(variant.id, { - inventory_quantity: onHand, + await this.manager_.transaction((m) => { + return this.productVariantService_ + .withTransaction(m) + .update(variant.id, { + inventory_quantity: onHand, + }) }) } }