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.

Unable to reserve cache with key node-cache-Linux-yarn, another job may be creating this cache

See original GitHub issue

Description: Seeing this error message in post job cleanup:

Failed to save: Unable to reserve cache with key node-cache-Linux-yarn-f7f2739226834f732cad92bce99b36aaa4e3ee50289107ffba1767a40681556e, another job may be creating this cache. More details: Cache already exists. Scope: refs/pull/897/merge, Key: node-cache-Linux-yarn-f7f2739226834f732cad92bce99b36aaa4e3ee50289107ffba1767a40681556e, Version: 73885106f58cc52a7df9ec4d4a5622a5614813162cb516c759a30af6bf56e6f0

Then the next run says

yarn cache is not found

I believe the issue could be the cache key doesn’t include the node-version so two concurrent jobs are trying to write to the same cache.

Action version: actions/setup-node@v3

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

  • node 14, 16
  • yarn 1

Repro steps:

jobs:
  test:
    name: Node ${{ matrix.node }} and ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        node: [14, 16]
    runs-on: ${{ matrix.os }}
    steps:
    - uses: actions/checkout@v3
    - name: Use Node.js ${{ matrix.node }}
      uses: actions/setup-node@v3
      with:
        cache: yarn
        node-version: ${{ matrix.node }}
        check-latest: true

https://github.com/vercel/ncc/blob/main/.github/workflows/ci.yml

https://github.com/vercel/ncc/actions/runs/3159786768/jobs/5145679888#step:19:7

Expected behavior: Cache to work

Actual behavior: Cache fails

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
dmitry-shibanovcommented, Sep 30, 2022

The action does not cache node_modules. It caches global dependencies that is why I think it should work as expected without specifying node version. For me information you can take a look at this pull request: https://github.com/actions/cache/pull/70

0reactions
styflecommented, Sep 30, 2022

@dmitry-shibanov What about native dependencies? Those don’t work properly between different versions of node.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to reserve cache with key X another job may ... - GitHub
The "Unable to reserve cache ..." error is not because of a race condition, but a known issue when something breaks between reserving...
Read more >
Caching dependencies in GitHub Actions | Lorenzo Bettini
and this message when the cache should be saved: Unable to reserve cache with key …, another job may be creating this cache....
Read more >
Clear cache in GitHub Actions - Stack Overflow
Once you create a cache, you cannot change the contents of an existing cache but you can create a new cache with a...
Read more >
7 Github Actions Tricks I Wish I Knew Before I Started
Another conditional can be to not trigger certain jobs for drafts : ... key: vivid-cache-build-${{ github.event.pull_request.head.sha }}.
Read more >
Concepts - CircleCI
Your CircleCI configuration can be adapted to fit many different needs of your ... To speed up the build, each job may contain...
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