Skip to content
Latchkey

GitHub Actions "Failed to save cache: reserveCache ... Cache already exists"

GitHub Actions cache entries are immutable; when two jobs try to save the same key concurrently, the second reserveCache call loses the race and reports the key already exists.

What this error means

A save step warns "Failed to save cache: reserveCache failed: Cache already exists. Scope: ..., Key: ...". The cache for that key still exists from the winning job.

github-actions
Failed to save cache: reserveCache failed: Cache already exists. Scope: refs/heads/main, Key: Linux-node-3f2a1b, Version: ...

Common causes

Concurrent jobs saving the same key

Parallel matrix legs or jobs computed the same key and raced to save; only the first reservation wins.

Key is too coarse

A key that does not vary per matrix dimension collides across legs that all try to save it.

How to fix it

Make keys unique or accept the race

  1. Add matrix dimensions (os, version, arch) to the key so legs do not collide.
  2. Treat the warning as benign when one save winning is acceptable.
  3. Centralize cache saving in a single job that others restore from.
.github/workflows/ci.yml
key: ${{ runner.os }}-${{ matrix.node }}-node-${{ hashFiles('**/package-lock.json') }}

How to prevent it

  • Include per-leg dimensions in cache keys.
  • Save shared caches from one job, restore in the rest.
  • Recognize the warning as harmless when expected.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →