Skip to content

Commit

Permalink
fix: race condition by awaiting each publish catalog function by type…
Browse files Browse the repository at this point in the history
… call.

Signed-off-by: Nat Hamilton <info@nathamilton.com>
  • Loading branch information
nnnnat committed Apr 26, 2019
1 parent c11020d commit 19c4e68
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,11 @@ export default async function createCatalogProduct(product, context) {
const catalogProduct = await xformProduct({ collections, product, shop, variants });

// Apply custom transformations from plugins.
getFunctionsOfType("publishProductToCatalog").forEach((customPublishFunc) => {
for (const customPublishFn of getFunctionsOfType("publishProductToCatalog")) {
// Functions of type "publishProductToCatalog" are expected to mutate the provided catalogProduct.
customPublishFunc(catalogProduct, { context, product, shop, variants });
});
// eslint-disable-next-line no-await-in-loop
await customPublishFn(catalogProduct, { context, product, shop, variants });
}

return catalogProduct;
}

0 comments on commit 19c4e68

Please sign in to comment.