Skip to content

fix: ensure order is preserved in Promise.all of adjustments#5920

Merged
yuda110 merged 1 commit intocloudforet-io:developfrom
yuda110:feature/ensure-promise-all
Jun 4, 2025
Merged

fix: ensure order is preserved in Promise.all of adjustments#5920
yuda110 merged 1 commit intocloudforet-io:developfrom
yuda110:feature/ensure-promise-all

Conversation

@yuda110
Copy link
Member

@yuda110 yuda110 commented Jun 4, 2025

Skip Review (optional)

  • Minor changes that don't affect the functionality (e.g. style, chore, ci, test, docs)
  • Previously reviewed in feature branch, further review is not mandatory
  • Self-merge allowed for solo developers or urgent changes

Description (optional)

Things to Talk About (optional)

Signed-off-by: yuda <yuda@megazone.com>
@vercel
Copy link

vercel bot commented Jun 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cost-report ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 4, 2025 2:25am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
console ⬜️ Ignored (Inspect) Visit Preview Jun 4, 2025 2:25am
web-storybook ⬜️ Ignored (Inspect) Visit Preview Jun 4, 2025 2:25am

@yuda110 yuda110 requested a review from Copilot June 4, 2025 02:22
@vercel
Copy link

vercel bot commented Jun 4, 2025

@yuda110 is attempting to deploy a commit to the cloudforet Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 4, 2025

🎉 @seungyeoneeee has been randomly selected as the reviewer! Please review. 🙏

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces concurrent Promise.all execution with sequential promise chaining to ensure that order is preserved during adjustment policy and adjustment processing.

  • Processes adjustment policies sequentially by replacing a map/Promise.all pattern with an async reduce chain.
  • Updates adjustment processing similarly to enforce sequential execution.
Comments suppressed due to low confidence (1)

apps/web/src/services/cost-explorer/components/AdvancedSettingsSetAdjustmentsOverlay.vue:235

  • The sequential processing of adjustments via reduce enforces order, but it may be less performant than parallel execution if order is not critical. Please confirm that preserving order is a necessary requirement.
await formPolicies.value.reduce(async (promise, policy) => {

Comment on lines +225 to +245
await formPolicies.value.reduce(async (promise, policy, idx) => {
await promise;
if (policy.id.startsWith('rap-')) {
return updateAdjustmentPolicy(policy, idx);
}
return createAdjustmentPolicy(policy, idx);
});
await Promise.all(policyPromises);
}, Promise.resolve());

// CUD Adjustment
await deleteAdjustment(deletedPolicyIds);
const adjustmentPromises = formPolicies.value.flatMap(async (policy) => {
await formPolicies.value.reduce(async (promise, policy) => {
await promise;
const adjustments = formAdjustments.value.filter((adjustment) => adjustment.policyId === policy.id);
return adjustments.map(async (adjustment, idx) => {
return adjustments.reduce(async (adjPromise, adjustment, idx) => {
await adjPromise;
if (adjustment.id.startsWith('ra-')) {
return updateAdjustment(adjustment, idx);
}
return createAdjustment(adjustment, idx);
});
});
const resolvedAdjustments = await Promise.all(adjustmentPromises);
await Promise.all(resolvedAdjustments.flat());
}, Promise.resolve());
}, Promise.resolve());
Copy link

Copilot AI Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to sequential execution ensures order preservation, but may introduce performance overhead with large policy arrays. Consider documenting the performance trade-off if sequential processing is required.

Copilot uses AI. Check for mistakes.
@yuda110 yuda110 merged commit 0758233 into cloudforet-io:develop Jun 4, 2025
7 checks passed
@yuda110 yuda110 deleted the feature/ensure-promise-all branch June 4, 2025 02:30
@yuda110 yuda110 restored the feature/ensure-promise-all branch June 4, 2025 02:34
@yuda110 yuda110 deleted the feature/ensure-promise-all branch June 4, 2025 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants