diff --git a/lib/util/got/cache-get.ts b/lib/util/got/cache-get.ts index 8ba6ae86e2ef74b70e4d6199d79e068d48e60f2d..00a034bf691e84efbc4f0205e38e8c307861acb7 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: async (options, next) => { + handler: (options, next) => { if (!global.repoCache) { return next(options); } @@ -24,18 +24,14 @@ export default create({ ) .digest('hex'); if (!global.repoCache[cacheKey] || options.useCache === false) { - global.repoCache[cacheKey] = next(options); - } - try { - const response = await global.repoCache[cacheKey]; - return { - ...response, - body: clone(response.body), - }; - } catch (err) { - delete global.repoCache[cacheKey]; - throw err; + global.repoCache[cacheKey] = next(options).on('error', () => { + delete global.repoCache[cacheKey]; + }); } + return global.repoCache[cacheKey].then(response => ({ + ...response, + body: clone(response.body), + })); } return next(options); },