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

Attemps to download .exe version for Linux when Node version not found in cache #714

Closed
2 of 5 tasks
domdomegg opened this issue Mar 15, 2023 · 5 comments · Fixed by #718
Closed
2 of 5 tasks

Attemps to download .exe version for Linux when Node version not found in cache #714

domdomegg opened this issue Mar 15, 2023 · 5 comments · Fixed by #718
Assignees
Labels
bug Something isn't working

Comments

@domdomegg
Copy link
Contributor

domdomegg commented Mar 15, 2023

Description:
When a node version is not found in the cache, for example when using 'current' or '19.8.1' at the moment, it appears that the action tries to download the .exe version despite running on a linux system.

Action version:
Specify the action version

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:
node: 'current' (resolved to v19.8.1)
package manager: npm

Repro steps:

GitHub workflow:

name: Repro
on: push
jobs:
  repro:
    runs-on: ubuntu-latest
    steps:
      - name: Use Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '19.8.1'

Expected behavior:
The action downloads the binaries from the node site.

Actual behavior:
The action attempts to download the .exe version, which fails.

Example logs:
https://github.com/domdomegg/typescript-library-template/actions/runs/4430005745/jobs/7771191230

getting latest node version...
Attempting to download v19.8.1...
Not found in manifest. Falling back to download directly from Node
Acquiring 19.8.1 - x64 from https://nodejs.org/dist/v19.8.1/node-v19.8.1-linux-x64.tar.gz
Downloading only node binary from https://nodejs.org/dist/v19.8.1/win-x64/node.exe
Error: Unexpected HTTP response: 404
@domdomegg domdomegg added bug Something isn't working needs triage labels Mar 15, 2023
@domdomegg
Copy link
Contributor Author

The issue appears to stem from:

protected async acquireNodeFromFallbackLocation(
version: string,
arch: string = os.arch()
): Promise<string> {
const initialUrl = this.getDistributionUrl();
const osArch: string = this.translateArchToDistUrl(arch);
// Create temporary folder to download in to
const tempDownloadFolder: string =
'temp_' + Math.floor(Math.random() * 2000000000);
const tempDirectory = process.env['RUNNER_TEMP'] || '';
assert.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined');
const tempDir: string = path.join(tempDirectory, tempDownloadFolder);
await io.mkdirP(tempDir);
let exeUrl: string;
let libUrl: string;
try {
exeUrl = `${initialUrl}/v${version}/win-${osArch}/node.exe`;
libUrl = `${initialUrl}/v${version}/win-${osArch}/node.lib`;
core.info(`Downloading only node binary from ${exeUrl}`);
const exePath = await tc.downloadTool(exeUrl);
await io.cp(exePath, path.join(tempDir, 'node.exe'));
const libPath = await tc.downloadTool(libUrl);
await io.cp(libPath, path.join(tempDir, 'node.lib'));
} catch (err) {
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
exeUrl = `${initialUrl}/v${version}/node.exe`;
libUrl = `${initialUrl}/v${version}/node.lib`;
const exePath = await tc.downloadTool(exeUrl);
await io.cp(exePath, path.join(tempDir, 'node.exe'));
const libPath = await tc.downloadTool(libUrl);
await io.cp(libPath, path.join(tempDir, 'node.lib'));
} else {
throw err;
}
}
const toolPath = await tc.cacheDir(tempDir, 'node', version, arch);
return toolPath;
}

@domdomegg
Copy link
Contributor Author

What's odd is that the logs would suggest it identified the right URL first time. And the code suggest it tried this but got a 404. However, that link seems to work when I try to hit it myself. So I'm quite uncertain why this is happening - maybe there's some odd caching going on given the version was released recently, and the action runners are hitting a different cache than me. But setup-node should handle this gracefully.

@domdomegg
Copy link
Contributor Author

After thinking more about this, there appear to be two bugs here:

  1. When things fail, we fallback to downloading windows binaries even when not on windows.
  2. Things fail due to caching errors on nodejs.org, where https://nodejs.org/dist/index.json says a version exists but the binaries are unavailable.

For clarity, this issue is dealing solely with issue 1.

I've created a separate issue, #717, for 2.

@dmitry-shibanov
Copy link
Contributor

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

@BorisTacyniak
Copy link

Hello @dmitry-shibanov

This issue is blocking pipelines, do you have an ETA on the investigation ?

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

Successfully merging a pull request may close this issue.

4 participants