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

core.setFailed fails if pass in an error straight from catch block #390

Closed
fishcharlie opened this issue Mar 24, 2020 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@fishcharlie
Copy link

Describe the bug

Passing an error directly into core.setFailed fails with random error ((s || "").replace is not a function).

To Reproduce
Steps to reproduce the behavior:

  1. Create failing action (example below)
  2. Ensure core.setFailed(e); instead of core.setFailed(`${e}`);
  3. Run GitHub Action

Expected behavior

It to fail with an error message of ERROR as opposed to a type error. Both core.setFailed(e); and core.setFailed(`${e}`); should produce the same result, they aren't currently.

Example Code

const core = require("@actions/core");

(async function (){
	try {
		throw new Error("ERROR");
	} catch (e) {
		core.setFailed(e);
	}
})();

Current behavior

(node:2682) UnhandledPromiseRejectionWarning: TypeError: (s || "").replace is not a function
10
    at escapeData (/.github/actions/installnpm/node_modules/@actions/core/lib/command.js:66:10)
11
    at Command.toString (/.github/actions/installnpm/node_modules/@actions/core/lib/command.js:60:35)
12
    at issueCommand (/.github/actions/installnpm/node_modules/@actions/core/lib/command.js:23:30)
13
    at Object.issue (/.github/actions/installnpm/node_modules/@actions/core/lib/command.js:27:5)
14
    at error (/.github/actions/installnpm/node_modules/@actions/core/lib/core.js:127:15)
15
    at Object.setFailed (/.github/actions/installnpm/node_modules/@actions/core/lib/core.js:101:5)
16
    at /.github/actions/installnpm/main.js:13:8
17
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
18
(node:2682) 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)
19

Other Notes

  • The bug was originally found in a failing await exec.exec command. I'm pretty confident that the code above will reproduce the issue, but if not, try doing it with a failing await exec.exec command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants