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.

Cache miss even tho key exists

See original GitHub issue

We’re using actions/cache@v3 in self-hosted runners (ubuntu-based).

We get a cache hit in one branch:

Cache restored successfully
Cache restored from key: v16.15.0-nodemodules-91bd5669329abf8e285e2b706e76bc9787848689b31ec5755f991616af28e407

Then, roughly an hour later, in a different branch (same workflow), we get a cache miss for the same key:

Cache not found for input keys: v16.15.0-nodemodules-91bd5669329abf8e285e2b706e76bc9787848689b31ec5755f991616af28e407

Why?

No other workflow runs took place between them.

This is the action we’re using:

name: 'Install Node dependencies'
description: 'Install Node dependencies'
author: 'proxyco'

inputs:
  path:
    default: '.'
    description: 'Location of node_modules'
    required: false
  node-version:
    description: 'The Node version'
    required: true

runs:
  using: "composite"
  steps:
    - name: Cache node_modules
      id: node-modules
      uses: actions/cache@v3
      with:
        path: ${{ inputs.path }}/node_modules
        key: ${{ inputs.node-version }}-nodemodules-${{ hashFiles(format('{0}/package-lock.json', inputs.path)) }}

    - name: Install dependencies
      if: steps.node-modules.outputs.cache-hit != 'true'
      # Skip post-install scripts here, as a malicious
      # script could steal NODE_AUTH_TOKEN.
      run: npm ci --ignore-scripts
      shell: bash
      working-directory: ${{ inputs.path }}

usage:

      - name: Set Node version
        run: echo ::set-output name=NODE_VERSION::$(node --version)
        id: nvm

      - name: Install dependencies
        uses: ./.github/actions/npm-install
        with:
          node-version: ${{ steps.nvm.outputs.NODE_VERSION }}

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:4
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
vsvipulcommented, Jul 10, 2022

@BeyondEvil Yes, this is expected. You will get a cache miss on a different branch if the cache save happened on a different branch with the same key, unless the save happens in the main/master branch, in which case all the other branches can access it. Please let me know if you have any more questions.

1reaction
aminyacommented, Aug 4, 2022

Secondly, here’s some info on Cache scopes, it is not a bug, rather a feature.

Not a good feature. It is undermining GitHub’s biggest feature which is making a pull request.

https://github.com/actions/cache/issues/79#issuecomment-1204808650

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cache miss is fired if Cache::has($key) returns false #12474
As for me, Cache miss means if a key exist on the server and was stored previously but retrieved value is null for...
Read more >
How is it possible that a key exists in cache but cannot be ...
Infinispan uses hashCode() to determine the segment (and owners) of a key. Internally, the data is stored in a ConcurrentHashMap . My guess...
Read more >
Cache miss attack - by Alex Xu - ByteByteGo Newsletter
If the key exists, the request first goes to the cache and then queries the database if needed. If the key doesn't exist...
Read more >
Alex Xu on Twitter: " Using Bloom filter. If the key exists, the ...
One of the issues is cache miss attack. Correct me if ... If the key exists, the request first goes to the cache...
Read more >
Create a disk cache object — diskCache - R Shiny
The missing and exec_missing parameters controls what happens when get() is called with a key that is not in the cache (a cache...
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