Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a promise.allSettle instead of a for loop that resolves one at a time #883

Merged
merged 7 commits into from
Jul 2, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/tree/azure/grouping/GroupingItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class GroupingItem implements ResourceGroupsItem {
items.push(new GenericItem('', { description: subscription.name }));
}

for await (const resource of subscriptionGroupingMap.get(subscription) ?? []) {
await Promise.allSettled((subscriptionGroupingMap.get(subscription) ?? []).map(async (resource): Promise<void> => {
try {
const branchDataProvider = this.branchDataProviderFactory(resource);
const resourceItem = await branchDataProvider.getResourceItem(resource);
Expand All @@ -125,7 +125,8 @@ export class GroupingItem implements ResourceGroupsItem {
} catch (e) {
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't have to be this PR but:

  • We should log this error.
  • And make sure it gets reported to telemetry.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oddly, this command doesn't pass in a context. It's a slightly bigger change to start pushing in a context everywhere for error telemetry, so I'll just log to output channel for now.

items.push(new InvalidAzureResourceItem(resource, e));
}
}
}));

return items;
}));

Expand Down
Loading