diff --git a/packages/core/strapi/lib/services/entity-service/components.js b/packages/core/strapi/lib/services/entity-service/components.js index dbde6f9855..26a60ab935 100644 --- a/packages/core/strapi/lib/services/entity-service/components.js +++ b/packages/core/strapi/lib/services/entity-service/components.js @@ -43,9 +43,10 @@ const createComponents = async (uid, data) => { throw new Error('Expected an array to create repeatable component'); } - const components = await Promise.all( - componentValue.map((value) => createComponent(componentUID, value)) - ); + const components = []; + for (const value of componentValue) { + components.push(await createComponent(componentUID, value)); + } componentBody[attributeName] = components.map(({ id }) => { return { @@ -77,18 +78,19 @@ const createComponents = async (uid, data) => { throw new Error('Expected an array to create repeatable component'); } - componentBody[attributeName] = await Promise.all( - dynamiczoneValues.map(async (value) => { - const { id } = await createComponent(value.__component, value); - return { - id, - __component: value.__component, - __pivot: { - field: attributeName, - }, - }; - }) - ); + const dynamicZoneData = []; + for (const value of dynamiczoneValues) { + const { id } = await createComponent(value.__component, value); + dynamicZoneData.push({ + id, + __component: value.__component, + __pivot: { + field: attributeName, + }, + }); + } + + componentBody[attributeName] = dynamicZoneData; continue; } @@ -137,9 +139,10 @@ const updateComponents = async (uid, entityToUpdate, data) => { throw new Error('Expected an array to create repeatable component'); } - const components = await Promise.all( - componentValue.map((value) => updateOrCreateComponent(componentUID, value)) - ); + const components = []; + for (const value of componentValue) { + components.push(await updateOrCreateComponent(componentUID, value)); + } componentBody[attributeName] = components.filter(_.negate(_.isNil)).map(({ id }) => { return { @@ -173,19 +176,19 @@ const updateComponents = async (uid, entityToUpdate, data) => { throw new Error('Expected an array to create repeatable component'); } - componentBody[attributeName] = await Promise.all( - dynamiczoneValues.map(async (value) => { - const { id } = await updateOrCreateComponent(value.__component, value); + const dynamicZoneData = []; + for (const value of dynamiczoneValues) { + const { id } = await updateOrCreateComponent(value.__component, value); + dynamicZoneData.push({ + id, + __component: value.__component, + __pivot: { + field: attributeName, + }, + }); + } - return { - id, - __component: value.__component, - __pivot: { - field: attributeName, - }, - }; - }) - ); + componentBody[attributeName] = dynamicZoneData; continue; } @@ -287,14 +290,14 @@ const deleteComponents = async (uid, entityToDelete, { loadComponents = true } = if (attribute.type === 'component') { const { component: componentUID } = attribute; - await Promise.all( - _.castArray(value).map((subValue) => deleteComponent(componentUID, subValue)) - ); + for (const subValue of _.castArray(value)) { + await deleteComponent(componentUID, subValue); + } } else { // delete dynamic zone components - await Promise.all( - _.castArray(value).map((subValue) => deleteComponent(subValue.__component, subValue)) - ); + for (const subValue of _.castArray(value)) { + await deleteComponent(subValue.__component, subValue); + } } continue; diff --git a/packages/core/upload/server/services/upload.js b/packages/core/upload/server/services/upload.js index b67b0cd58e..9d84f68368 100644 --- a/packages/core/upload/server/services/upload.js +++ b/packages/core/upload/server/services/upload.js @@ -228,6 +228,7 @@ module.exports = ({ strapi }) => ({ const formats = await generateResponsiveFormats(fileData); if (Array.isArray(formats) && formats.length > 0) { for (const format of formats) { + // eslint-disable-next-line no-continue if (!format) continue; uploadPromises.push(uploadResponsiveFormat(format)); } diff --git a/packages/plugins/i18n/server/services/localizations.js b/packages/plugins/i18n/server/services/localizations.js index 05a7e7b4a4..96bed4dbab 100644 --- a/packages/plugins/i18n/server/services/localizations.js +++ b/packages/plugins/i18n/server/services/localizations.js @@ -32,7 +32,9 @@ const syncLocalizations = async (entry, { model }) => { return strapi.query(model.uid).update({ where: { id }, data: { localizations } }); }; - await Promise.all(entry.localizations.map(({ id }) => updateLocalization(id))); + for (const localization of entry.localizations) { + await updateLocalization(localization.id); + } } }; @@ -56,7 +58,9 @@ const syncNonLocalizedAttributes = async (entry, { model }) => { return strapi.entityService.update(model.uid, id, { data: nonLocalizedAttributes }); }; - await Promise.all(entry.localizations.map(({ id }) => updateLocalization(id))); + for (const localization of entry.localizations) { + await updateLocalization(localization.id); + } } };