pozil / auto-assign-issue

GitHub Action that auto-assigns issues or PRs to one or more users
Creative Commons Zero v1.0 Universal
53 stars 32 forks source link

fix: octokit instance is now grabbed using a function call #7

Closed TomerFi closed 3 years ago

TomerFi commented 3 years ago

As mention in this issue, The action has stopped working, throwing the following (but not failing the workflow):

(node:2419) UnhandledPromiseRejectionWarning: TypeError: github.GitHub is not a constructor
    at run (/home/runner/work/_actions/pozil/auto-assign-issue/v1.0.2/src/index.js:7:21)
    at Object.<anonymous> (/home/runner/work/_actions/pozil/auto-assign-issue/v1.0.2/src/index.js:39:5)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
    at internal/main/run_main_module.js:17:11
(node:2419) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2419) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

There are two issues to be addressed here if I understand this correctly. The first issue, fixed in this PR is the cause for the error:

TypeError: github.GitHub is not a constructor

As you can see in this commit for @actions/github: the concrete class GitHub extending Octokit is removed. An Octokit instance is now grabbed using the getOctokit function. It is of course also updated in the README file updated in the same commit.

The second issue to be addressed, not fixed in this PR is the deprecation notice:

(node:2419) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2419) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

If I understand this correctly, the reason for the original error not failing the build is exactly what is being addressed in the deprecation notice. The currently failing instantiation of the Github class, is failing inside an async function and should be caught and used in conjunction with core.setFailed.

But that's outside the scope of the PR for now (maybe for the next one). This PR should close (at least one aspect of) #6 .