From c015a6a3f410f12f58255c3d085fd774312f7a2f Mon Sep 17 00:00:00 2001 From: Philippe Ozil Date: Fri, 3 Jan 2025 10:52:48 +0100 Subject: [PATCH] fix: parallel check requests and error handling (#150) * fix: parallel check requests and error handling * build: release v2.1.2 --- node_modules/.package-lock.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/__tests__/action.test.js | 2 +- src/utils.js | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 6a053696..75b41d62 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -1,6 +1,6 @@ { "name": "auto-assign-issue", - "version": "2.1.1", + "version": "2.1.2", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package-lock.json b/package-lock.json index e79188eb..0feddfe2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "auto-assign-issue", - "version": "2.1.1", + "version": "2.1.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "auto-assign-issue", - "version": "2.1.1", + "version": "2.1.2", "license": "CC0-1.0", "dependencies": { "@actions/core": "^1.11.1", diff --git a/package.json b/package.json index 6761fcff..83f01fa0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "auto-assign-issue", - "version": "2.1.1", + "version": "2.1.2", "private": true, "description": "GitHub action that auto-assigns issues to users", "main": "src/index.js", diff --git a/src/__tests__/action.test.js b/src/__tests__/action.test.js index 585111b5..a58dcb82 100644 --- a/src/__tests__/action.test.js +++ b/src/__tests__/action.test.js @@ -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( diff --git a/src/utils.js b/src/utils.js index a13b658a..bd40de1c 100644 --- a/src/utils.js +++ b/src/utils.js @@ -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]); }