-
Notifications
You must be signed in to change notification settings - Fork 16
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
Replace all promise.All with promise.allSettled #122
Replace all promise.All with promise.allSettled #122
Conversation
await Promise.all(groupIds.map((groupId) => disconnectGroup(groupId, cloudId, forgeAppId))); | ||
const groupIds = await getGroupIds(); | ||
|
||
const result = await Promise.allSettled(groupIds.map((groupId) => disconnectGroup(groupId, cloudId, forgeAppId))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I'd recommend to call these results
since it's a collection.
@@ -3,6 +3,7 @@ import { getTrackingBranchName } from '../../../services/get-tracking-branch'; | |||
import { MergeRequestEvent } from '../../../types'; | |||
import { insertMetricValues } from '../../../services/insert-metric-values'; | |||
import { getMRCycleTime, getOpenMergeRequestsCount } from '../../../services/compute-event-and-metrics'; | |||
import { ALL_SETTLED_STATUS, getFormattedErrors } from '../../../utils/promise-allsettled-helpers'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea extracting these statuses to a constant.
|
||
const promisesResponse = await Promise.all(getDeploymentsPromises); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A single error here would have bubbled up. It looks like the new code is silently catching errors and returning an empty array. Do we want to change that behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, maybe better throw error in catch
block, or remove try catch
, because getDeploymentAfter28Days
is used in hasDeploymentAfter28Days
, and this method also is called in Promise.allSettled
that is in try catch
block. But the better option it's remove try catch
block to stay the same logic
Description
Replaced all
Promise.all
withPromise.allSettled
Checklist
Please ensure that each of these items has been addressed: