question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nodejs binary is not cached

See original GitHub issue

Description: The nodejs binary is not cached, setup-node downloads it from https://github.com/actions/node-versions/releases on every run.

Action version: Latest

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version: node 16.15.1

Repro steps:

    - name: "Set up nodejs"
      uses: actions/setup-node@v3
      with:
        node-version-file: '.nvmrc'

In a composite action.

Expected behavior: Nodejs binary should be pulled from the cache, not downloaded every time.

Actual behavior: Logs showing the issue:

Resolved .nvmrc as 16.15.1
Attempting to download 16.15.1...
Acquiring 16.15.1 - x64 from https://github.com/actions/node-versions/releases/download/16.15.1-2426430333/node-16.15.1-linux-x64.tar.gz
Extracting ...
/usr/bin/tar xz --strip 1 --warning=no-unknown-keyword -C /home/runner/work/_temp/fa1f695b-6acd-4867-b040-2ef9482f9b49 -f /home/runner/work/_temp/1f3d7c09-4341-4773-9225-73d14d319922
Adding to the cache ...
Done

In the logs above we see “Adding to the cache …”, but on a subsequent run the same happens (.i.e. nodejs is downloaded from node-versions/releases). This means that a subsequent runs also shows “Attempting to download 16.15.1…” although the binary should come from the cache this time.

I also tried to set the nodejs version directly (without a file), same issue.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jpike88commented, Aug 22, 2022

Sorry I switched tabs and read the wrong repo name! Ignore my last message.

I think there should be a simple improvement that checks downloadPath to see if there’s already a matching binary there, that way we can use other caching actions to leverage this. Should be simple enough right

0reactions
dmitry-shibanovcommented, Aug 22, 2022

Hello everyone. Hosted images have preinstalled versions of Nodejs in hosted toolcache directory, the action can utilize them. According to documentation the action caches global package dependencies. The action does not cache node_modules.

When the job is finished the hosted runners get cleaned to the initial state that is why the Nodejs will be installing for next jobs.

For now I’m going to close the issue because it’s an expected behaviour.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - npm install force to not use binary cache and rebuild ...
I want to reproduce the error by forcing node to rebuild those packages, but I've not been able to. I tried this command:...
Read more >
The compiled binary should be also cached. #1882 - GitHub
I find the compiled binary not be cached in ~/.npm/node-sass . So If the node-modules/ dir removed will download or compile again.
Read more >
Nodejs cache images or other binary data on local disk ...
I've been looking for a simple npm package that will allow caching arbitrary binary data (images, specifically) on a local fs storage.
Read more >
Caching In Node.js Applications - Honeybadger Developer Blog
Caching is a common technique for making your applications faster. It lets you avoid slow operations by reusing previous results.
Read more >
cache-manager-fs-binary - npm package - Snyk
The npm package cache-manager-fs-binary was scanned for known vulnerabilities and missing license, and no issues were found. Thus the package was deemed as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found