Skip to content
Next Next commit
Handle ReserveCacheError with a nicer message
  • Loading branch information
mbg committed Nov 12, 2024
commit b0c0aadc56663a4555f83f707b1811a9b4add99c
19 changes: 17 additions & 2 deletions lib/dependency-caching.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/dependency-caching.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions src/dependency-caching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,25 @@ export async function uploadDependencyCaches(config: Config, logger: Logger) {
const key = await cacheKey(language, cacheConfig);

logger.info(
`Uploading cache of size ${size} for ${language} with key ${key}`,
`Uploading cache of size ${size} for ${language} with key ${key}...`,
);

await actionsCache.saveCache(cacheConfig.paths, 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;
}
}
}
}

Expand Down