From 052500fbf88296d55d31c88ae01f361994170ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matheus=20Gaudencio=20do=20R=C3=AAgo?= Date: Thu, 13 Feb 2025 11:53:24 -0300 Subject: [PATCH] Fix leak on linx promise all (#1006) --- linx/loaders/product/list.ts | 26 ++++++++++++++------------ linx/loaders/product/listingPage.ts | 24 ++++++++++++------------ 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/linx/loaders/product/list.ts b/linx/loaders/product/list.ts index 7d720e16b..1468f4e19 100644 --- a/linx/loaders/product/list.ts +++ b/linx/loaders/product/list.ts @@ -39,18 +39,20 @@ const loader = async ( const products = response?.Model?.Grid?.Products ?? []; - return await Promise.all( - products.map(async (product) => - await addAuctions( - toProduct(product, product.ProductSelection?.SkuID, { - cdn, - url, - currency: "BRL", - }), - ctx, - ) - ), - ); + const transformedProducts = []; + for (const product of products) { + const transformedProduct = await addAuctions( + toProduct(product, product.ProductSelection?.SkuID, { + cdn, + url, + currency: "BRL", + }), + ctx, + ); + transformedProducts.push(transformedProduct); + } + + return transformedProducts; }; export default loader; diff --git a/linx/loaders/product/listingPage.ts b/linx/loaders/product/listingPage.ts index 416f1a16e..c742cde68 100644 --- a/linx/loaders/product/listingPage.ts +++ b/linx/loaders/product/listingPage.ts @@ -78,18 +78,18 @@ const loader = async ( } = forProducts; const { Model: { Grid: { Facets } } } = forProducts; - const products = await Promise.all( - Products.map(async (product) => - await addAuctions( - toProduct(product, product.ProductSelection?.SkuID, { - cdn, - currency: "BRL", - url, - }), - ctx, - ) - ), - ); + const products = []; + for (const product of Products) { + const transformedProduct = await addAuctions( + toProduct(product, product.ProductSelection?.SkuID, { + cdn, + currency: "BRL", + url, + }), + ctx, + ); + products.push(transformedProduct); + } return { "@type": "ProductListingPage",