Skip to content

Commit b0c0aad

Browse files
committed
Handle ReserveCacheError with a nicer message
1 parent 5cb4249 commit b0c0aad

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

Diff for: lib/dependency-caching.js

+17-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: lib/dependency-caching.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/dependency-caching.ts

+17-2
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,25 @@ export async function uploadDependencyCaches(config: Config, logger: Logger) {
181181
const key = await cacheKey(language, cacheConfig);
182182

183183
logger.info(
184-
`Uploading cache of size ${size} for ${language} with key ${key}`,
184+
`Uploading cache of size ${size} for ${language} with key ${key}...`,
185185
);
186186

187-
await actionsCache.saveCache(cacheConfig.paths, key);
187+
try {
188+
await actionsCache.saveCache(cacheConfig.paths, key);
189+
} catch (error) {
190+
// `ReserveCacheError` indicates that the cache key is already in use, which means that a
191+
// cache with that key already exists or is in the process of being uploaded by another
192+
// workflow. We can ignore this.
193+
if (error instanceof actionsCache.ReserveCacheError) {
194+
logger.info(
195+
`Not uploading cache for ${language}, because ${key} is already in use.`,
196+
);
197+
logger.debug(error.message);
198+
} else {
199+
// Propagate other errors upwards.
200+
throw error;
201+
}
202+
}
188203
}
189204
}
190205

0 commit comments

Comments
 (0)