Skip to content

Commit

Permalink
Handle ReserveCacheError with a nicer message
Browse files Browse the repository at this point in the history
  • Loading branch information
mbg committed Nov 12, 2024
1 parent 5cb4249 commit b0c0aad
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
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

0 comments on commit b0c0aad

Please sign in to comment.