diff --git a/awx/ui_next/src/api/mixins/InstanceGroups.mixin.js b/awx/ui_next/src/api/mixins/InstanceGroups.mixin.js index c82909df47..0030588c25 100644 --- a/awx/ui_next/src/api/mixins/InstanceGroups.mixin.js +++ b/awx/ui_next/src/api/mixins/InstanceGroups.mixin.js @@ -30,6 +30,7 @@ const InstanceGroupsMixin = parent => async orderInstanceGroups(resourceId, current, original) { /* eslint-disable no-await-in-loop, no-restricted-syntax */ + // Resolve Promises sequentially to maintain order and avoid race condition if (!isEqual(current, original)) { for (const group of original) { await this.disassociateInstanceGroup(resourceId, group.id); diff --git a/awx/ui_next/src/screens/Inventory/InventoryAdd/InventoryAdd.jsx b/awx/ui_next/src/screens/Inventory/InventoryAdd/InventoryAdd.jsx index 703ab9a946..79d756aecd 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryAdd/InventoryAdd.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryAdd/InventoryAdd.jsx @@ -24,6 +24,7 @@ function InventoryAdd() { ...remainingValues, }); /* eslint-disable no-await-in-loop, no-restricted-syntax */ + // Resolve Promises sequentially to maintain order and avoid race condition for (const group of instanceGroups) { await InventoriesAPI.associateInstanceGroup(inventoryId, group.id); } diff --git a/awx/ui_next/src/screens/Inventory/SmartInventoryAdd/SmartInventoryAdd.jsx b/awx/ui_next/src/screens/Inventory/SmartInventoryAdd/SmartInventoryAdd.jsx index 91ec24df6d..5eed709d41 100644 --- a/awx/ui_next/src/screens/Inventory/SmartInventoryAdd/SmartInventoryAdd.jsx +++ b/awx/ui_next/src/screens/Inventory/SmartInventoryAdd/SmartInventoryAdd.jsx @@ -20,6 +20,7 @@ function SmartInventoryAdd() { } = await InventoriesAPI.create(values); /* eslint-disable no-await-in-loop, no-restricted-syntax */ + // Resolve Promises sequentially to maintain order and avoid race condition for (const group of groupsToAssociate) { await InventoriesAPI.associateInstanceGroup(invId, group.id); } diff --git a/awx/ui_next/src/screens/Template/JobTemplateAdd/JobTemplateAdd.jsx b/awx/ui_next/src/screens/Template/JobTemplateAdd/JobTemplateAdd.jsx index 89a387cb33..de5ff19d6d 100644 --- a/awx/ui_next/src/screens/Template/JobTemplateAdd/JobTemplateAdd.jsx +++ b/awx/ui_next/src/screens/Template/JobTemplateAdd/JobTemplateAdd.jsx @@ -65,6 +65,7 @@ function JobTemplateAdd() { async function submitInstanceGroups(templateId, addedGroups = []) { /* eslint-disable no-await-in-loop, no-restricted-syntax */ + // Resolve Promises sequentially to maintain order and avoid race condition for (const group of addedGroups) { await JobTemplatesAPI.associateInstanceGroup(templateId, group.id); }