diff --git a/lib/util/got/cache-get.ts b/lib/util/got/cache-get.ts index 60351f4d2155d99cf01576eb42d5586288e91fc8..8ba6ae86e2ef74b70e4d6199d79e068d48e60f2d 100644 --- a/lib/util/got/cache-get.ts +++ b/lib/util/got/cache-get.ts @@ -8,7 +8,7 @@ import { clone } from '../clone'; // istanbul ignore next export default create({ options: {}, - handler: (options, next) => { + handler: async (options, next) => { if (!global.repoCache) { return next(options); } @@ -26,10 +26,16 @@ export default create({ if (!global.repoCache[cacheKey] || options.useCache === false) { global.repoCache[cacheKey] = next(options); } - return global.repoCache[cacheKey].then(response => ({ - ...response, - body: clone(response.body), - })); + try { + const response = await global.repoCache[cacheKey]; + return { + ...response, + body: clone(response.body), + }; + } catch (err) { + delete global.repoCache[cacheKey]; + throw err; + } } return next(options); },