mirror of
https://github.com/strapi/strapi.git
synced 2025-11-16 10:07:55 +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');
|
throw new Error('Expected an array to create repeatable component');
|
||||||
}
|
}
|
||||||
|
|
||||||
const components = await Promise.all(
|
const components = [];
|
||||||
componentValue.map((value) => createComponent(componentUID, value))
|
for (const value of componentValue) {
|
||||||
);
|
components.push(await createComponent(componentUID, value));
|
||||||
|
}
|
||||||
|
|
||||||
componentBody[attributeName] = components.map(({ id }) => {
|
componentBody[attributeName] = components.map(({ id }) => {
|
||||||
return {
|
return {
|
||||||
@ -77,18 +78,19 @@ const createComponents = async (uid, data) => {
|
|||||||
throw new Error('Expected an array to create repeatable component');
|
throw new Error('Expected an array to create repeatable component');
|
||||||
}
|
}
|
||||||
|
|
||||||
componentBody[attributeName] = await Promise.all(
|
const dynamicZoneData = [];
|
||||||
dynamiczoneValues.map(async (value) => {
|
for (const value of dynamiczoneValues) {
|
||||||
const { id } = await createComponent(value.__component, value);
|
const { id } = await createComponent(value.__component, value);
|
||||||
return {
|
dynamicZoneData.push({
|
||||||
id,
|
id,
|
||||||
__component: value.__component,
|
__component: value.__component,
|
||||||
__pivot: {
|
__pivot: {
|
||||||
field: attributeName,
|
field: attributeName,
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
})
|
}
|
||||||
);
|
|
||||||
|
componentBody[attributeName] = dynamicZoneData;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -137,9 +139,10 @@ const updateComponents = async (uid, entityToUpdate, data) => {
|
|||||||
throw new Error('Expected an array to create repeatable component');
|
throw new Error('Expected an array to create repeatable component');
|
||||||
}
|
}
|
||||||
|
|
||||||
const components = await Promise.all(
|
const components = [];
|
||||||
componentValue.map((value) => updateOrCreateComponent(componentUID, value))
|
for (const value of componentValue) {
|
||||||
);
|
components.push(await updateOrCreateComponent(componentUID, value));
|
||||||
|
}
|
||||||
|
|
||||||
componentBody[attributeName] = components.filter(_.negate(_.isNil)).map(({ id }) => {
|
componentBody[attributeName] = components.filter(_.negate(_.isNil)).map(({ id }) => {
|
||||||
return {
|
return {
|
||||||
@ -173,19 +176,19 @@ const updateComponents = async (uid, entityToUpdate, data) => {
|
|||||||
throw new Error('Expected an array to create repeatable component');
|
throw new Error('Expected an array to create repeatable component');
|
||||||
}
|
}
|
||||||
|
|
||||||
componentBody[attributeName] = await Promise.all(
|
const dynamicZoneData = [];
|
||||||
dynamiczoneValues.map(async (value) => {
|
for (const value of dynamiczoneValues) {
|
||||||
const { id } = await updateOrCreateComponent(value.__component, value);
|
const { id } = await updateOrCreateComponent(value.__component, value);
|
||||||
|
dynamicZoneData.push({
|
||||||
|
id,
|
||||||
|
__component: value.__component,
|
||||||
|
__pivot: {
|
||||||
|
field: attributeName,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
componentBody[attributeName] = dynamicZoneData;
|
||||||
id,
|
|
||||||
__component: value.__component,
|
|
||||||
__pivot: {
|
|
||||||
field: attributeName,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -287,14 +290,14 @@ const deleteComponents = async (uid, entityToDelete, { loadComponents = true } =
|
|||||||
|
|
||||||
if (attribute.type === 'component') {
|
if (attribute.type === 'component') {
|
||||||
const { component: componentUID } = attribute;
|
const { component: componentUID } = attribute;
|
||||||
await Promise.all(
|
for (const subValue of _.castArray(value)) {
|
||||||
_.castArray(value).map((subValue) => deleteComponent(componentUID, subValue))
|
await deleteComponent(componentUID, subValue);
|
||||||
);
|
}
|
||||||
} else {
|
} else {
|
||||||
// delete dynamic zone components
|
// delete dynamic zone components
|
||||||
await Promise.all(
|
for (const subValue of _.castArray(value)) {
|
||||||
_.castArray(value).map((subValue) => deleteComponent(subValue.__component, subValue))
|
await deleteComponent(subValue.__component, subValue);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -228,6 +228,7 @@ module.exports = ({ strapi }) => ({
|
|||||||
const formats = await generateResponsiveFormats(fileData);
|
const formats = await generateResponsiveFormats(fileData);
|
||||||
if (Array.isArray(formats) && formats.length > 0) {
|
if (Array.isArray(formats) && formats.length > 0) {
|
||||||
for (const format of formats) {
|
for (const format of formats) {
|
||||||
|
// eslint-disable-next-line no-continue
|
||||||
if (!format) continue;
|
if (!format) continue;
|
||||||
uploadPromises.push(uploadResponsiveFormat(format));
|
uploadPromises.push(uploadResponsiveFormat(format));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,9 @@ const syncLocalizations = async (entry, { model }) => {
|
|||||||
return strapi.query(model.uid).update({ where: { id }, data: { localizations } });
|
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 });
|
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