actions / setup-node

Set up your GitHub Actions workflow with a specific version of node.js
MIT License
3.91k stars 1.29k forks source link

Hang on Windows after "Adding to the cache ..." #720

Open kevinoid opened 1 year ago

kevinoid commented 1 year ago

Description: In one of my repositories, actions/setup-node hangs after "Adding to the cache ..." until the job times out.

Action version: v3

Platform:

Runner type:

Tools version: I've observed the error with node-version: '14.18' and node-version: '>=17.1'.

Repro steps:

I'm observing the issue in my eslint-config-kevinoid repository. I've created a minimal workflow which reproduces the issue which produced this failing workflow run.

Minimal Workflow Issue Reproduction YAML ```yaml name: Failing Workflow on: push: {} workflow_dispatch: {} jobs: test: name: Node ${{ matrix.node }} ${{ matrix.arch }} on ${{ matrix.os }} timeout-minutes: 5 runs-on: ${{ matrix.os }} strategy: matrix: arch: - x64 os: - windows-latest node: - '14.18' steps: - uses: actions/checkout@v3 - name: Set up Node.js ${{ matrix.node }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} architecture: ${{ matrix.arch }} check-latest: ${{ matrix.node == '*' }} ```

Note that the 5 minute timeout in the reproduction was added arbitrarily to make the issue easier to test and demonstrate. The original workflow actions/setup-node@v3 failed after 6 hours.

Also note that the issue does not occur if the actions/checkout@v3 step is removed.

Expected behavior: The actions/setup-node@v3 step would complete in a reasonable amount of time.

Actual behavior: The actions/setup-node@v3 step does not complete after 5 minutes (or 6 hours).

dmitry-shibanov commented 1 year ago

Hello @kevinoid. Thank you for your report. We'll investigate the issue.

kevinoid commented 1 year ago

@dmitry-shibanov Were you able to investigate the issue? Is there anything else that I can do to assist? It appears that builds are still hanging in "Adding to the cache ...".

dusan-trickovic commented 1 year ago

Hello, @kevinoid ! I'm sorry for the late response, I just wanted to give you a little ping to see if your issue resolved in the meantime? :)

kevinoid commented 1 year ago

Hi @dusan-trickovic, Thanks for checking in! Nope, it's still not resolved. Is there anything I can do to help investigate?

dusan-trickovic commented 1 year ago

Understood. I will investigate it and reach out to you again when I have a solution or if I need some more clarification (or at least when I have some updates / suggestions). Thank you very much for your cooperation! :)

kevinoid commented 1 year ago

I've determined the cause of the issue: The invocation of C:\npm\prefix\yarn.cmd --version in printEnvDetailsAndSetOutput() hangs due to the presence of a file named node.js in the repository. This occurs because of a regression (https://github.com/npm/cmd-shim/pull/64 https://github.com/npm/cmd-shim/issues/71) in the .cmd shim generated for yarn by recent versions of npm which invokes node.js instead of node.exe.

Although the root cause of the issue is not in setup-node, I would suggest adding a reasonable timeout for the --version invocations along with a useful error message to aid future users affected by similar issues.

dusan-trickovic commented 1 year ago

Hi, @kevinoid ! Thanks for the update, I'm glad you've found the culprit behind this issue :) And thank you for the suggestion - I will investigate it and forward it to my team as well :)