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

Reject promise and return on error #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tobyjsullivan
Copy link

Problem

When there is an error in the upload process, two different errors are printed to console with the second being a non-obvious code error. This can be confusing for the person troubleshooting.

Example:

Error: AccessControlListNotSupported: The bucket does not allow ACLs
/home/runner/work/_actions/shallwefootball/upload-s3-action/v1.2.0/dist/index.js:11396
            throw err;
            ^

Error [TypeError]: Cannot read properties of undefined (reading 'Key')
    at ManagedUpload.callback (/home/runner/work/_actions/shallwefootball/upload-s3-action/v1.2.0/dist/index.js:28879:36)
    at Response.finishSinglePart (/home/runner/work/_actions/shallwefootball/upload-s3-action/v1.2.0/dist/index.js:13280:28)
    at Request.<anonymous> (/home/runner/work/_actions/shallwefootball/upload-s3-action/v1.2.0/dist/index.js:11732:18)
    at Request.callListeners (/home/runner/work/_actions/shallwefootball/upload-s3-action/v1.2.0/dist/index.js:13445:20)
    at Request.emit (/home/runner/work/_actions/shallwefootball/upload-s3-action/v1.2.0/dist/index.js:13417:10)
    at Request.emit (/home/runner/work/_actions/shallwefootball/upload-s3-action/v1.2.0/dist/index.js:12051:14)
    at Request.transition (/home/runner/work/_actions/shallwefootball/upload-s3-action/v1.2.0/dist/index.js:11387:10)
    at AcceptorStateMachine.runTo (/home/runner/work/_actions/shallwefootball/upload-s3-action/v1.2.0/dist/index.js:17191:12)
    at /home/runner/work/_actions/shallwefootball/upload-s3-action/v1.2.0/dist/index.js:17203:10
    at Request.<anonymous> (/home/runner/work/_actions/shallwefootball/upload-s3-action/v1.2.0/dist/index.js:11403:9) {
  code: 'TypeError',
  time: 2022-12-14T20:02:01.354Z
}

The second error (TypeError) is thrown when we attempt to log out a success message when data is undefined.

core.info(`uploaded - ${data.Key}`);

Solution

Reject the promise and return from the callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant