Skip to content

Commit

Permalink
fix: parallel check requests and error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
pozil committed Jan 3, 2025
1 parent f09bc3b commit 2124ca1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ describe('action', () => {
});

it('fails if user cannot be assigned and failsIfUsersCannotBeAssigned flag is true', async () => {
const requestMock = jest.fn(() => Promise.resolve({ status: 404 }));
const requestMock = jest.fn(() => Promise.reject({ status: 404 }));
const octokitMock = getOctokitMock({ requestMock });

await expect(
Expand Down
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ const checkIfUsersCanBeAssigned = async (
);
requests.push(request);
}
const responses = await Promise.all(requests);
const responses = await Promise.allSettled(requests);
const result = { isSuccess: true, assigneeErrors: [] };
for (let i = 0; i < assignees.length; i++) {
const { status } = responses[i];
if (status != 204) {
if (status === 'rejected') {
result.isSuccess = false;
result.assigneeErrors.push(assignees[i]);
}
Expand Down

0 comments on commit 2124ca1

Please sign in to comment.