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.
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
- Add matrix dimensions (os, version, arch) to the key so legs do not collide.
- Treat the warning as benign when one save winning is acceptable.
- Centralize cache saving in a single job that others restore from.
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.