mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 10:23:34 +00:00
Merge pull request #15535 from strapi/fix/sequential-requests-deadlock
Prevent deadlocks on components and locale updates
This commit is contained in:
commit
c909df5d45
@ -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;
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user