TypeError: core.setFailed

Hi, I’m trying to set up a testing workflow for our repository. Im new to github actions, so i just want to test whether i can make the test fails with action/toolkit. Here’s the script im trying to run:

import * as core from '@actions/core'

async function run(): Promise<void> {
 try {
    throw new Error('i just want to set you failed!')
  } catch (error) {


After build and run, it gives me an error:

I felt like it’s some kind of building error, but there’s no error when build it. Could you help me with that? Thank you !

Actions toolkit version: “@actions/core”: “^1.2.4”
The link to the original code :

Hi @sun765,

Glad to see you in Github Community Forum!

It seems like a code issue since it doen’s reproduce on another branch ‘update-filament-goldens’ with same yaml code.

Checked in my workflow: https://github.com/weide-zhou/model-viewer/runs/913030863?check_suite_focus=true#step:10:1

I didn’t find the error code (try… catch…), is it somewhere else?


Hi @weide-zhou, thanks for the reply! I looked further on this problem, and here’s what i found:

  1. In the debugger, the imported core object is empty
  2. If i use "import {setFailed} from ‘@ action/core’, (put an extra space otherwise the system will think im mentioning someone)it gives this error ( runtime error, and it can be built successfuly):
    import { setFailed } from ‘@ actions/core’;
    SyntaxError: The requested module ‘@ actions/core’ is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.

Then i noticed on difference between my tsconfig.json and the one in your typescript-template project, our module option is set to be ESnext, and yours is commonJS. Im not quite farmaliar with module option, but do you think that this maybe a conflict between these two module system?

Here’s link of our tsconfig file:

link of our rollup.config.js file:

Thank you!

Hi @sun765,

Thanks for your reply!

Could you please let me know where did you check the tsconfig.json?
I just forked your repository and find it’s successful on another branch with same yaml code. The tsconfig file is same: https://github.com/weide-zhou/model-viewer/blob/f260c16ffa6a4fe542a6ec79abfe616d6fb51ffa/packages/render-fidelity-tools/tsconfig.json

Let’s move back the original error, is it same with this ticket?


Hi @weide-zhou,

Thanks for the reply!
The tsconfig file i was talking about is from the typescript-action template repo.

As for the original error, it’s not same with that ticket. That one is about passing the correct type of argument to setFail, mine is that the whole module is not imported correctly and the imported core module is just an empty object.

I actually found a workaround for this by using commonJs “require()” instead of “import” to import the action/core package. https://github.com/google/model-viewer/pull/1404/files#diff-30462649f1aa00e7bbbdc7de66053c02R4 But i still don’t understand why this will cause problem. If you could help me understand that i will really appreciate it. Thanks!

1 Like