Strange (buggy?) caching behaviour



A branch of my nodejs project has been failing on cache retrieval issues for a while

Initially I was building my cache key from package.json, but on reading how caches are harder to bust in circleci 2.0, I’ve now changed to committing package-lock.json and using that as the cache key. But I still get failures, and pretty weird ones:

The cache key generated when saving to cache is dependency-cache-atq4gqwOq2wnMOKvehgYFGyAyNaKr7DuHDD_H0BM5YY=

But the cache key generated when retrieving the cache is dependency-cache-vQdJyD32GUffAiOk8gJYu5zD9CwWOJRQT0QF0jbqK5I=. However, one job succeeds using this key (which shouldn’t correspond to any existing caches), and all the other jobs fail.

Can anyone explain this behaviour?

github branch:


Solved it. For some versions of npm there’s a bug/feature that means npm install will override the committed package-lock.json, hence its checksum is no longer a reliable key to use for naming the cache.

I solved this by using npm install --no-package-lock in CI only


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.