Handle ReserveCacheError with a nicer message

This commit is contained in:
Michael B. Gale 2024-11-12 15:08:09 +00:00
parent 5cb4249dc7
commit b0c0aadc56
No known key found for this signature in database
GPG key ID: FF5E2765BD00628F
3 changed files with 35 additions and 5 deletions

View file

@ -147,8 +147,23 @@ async function uploadDependencyCaches(config, logger) {
continue;
}
const key = await cacheKey(language, cacheConfig);
logger.info(`Uploading cache of size ${size} for ${language} with key ${key}`);
await actionsCache.saveCache(cacheConfig.paths, key);
logger.info(`Uploading cache of size ${size} for ${language} with key ${key}...`);
try {
await actionsCache.saveCache(cacheConfig.paths, key);
}
catch (error) {
// `ReserveCacheError` indicates that the cache key is already in use, which means that a
// cache with that key already exists or is in the process of being uploaded by another
// workflow. We can ignore this.
if (error instanceof actionsCache.ReserveCacheError) {
logger.info(`Not uploading cache for ${language}, because ${key} is already in use.`);
logger.debug(error.message);
}
else {
// Propagate other errors upwards.
throw error;
}
}
}
}
/**