diff --git a/lib/util/cache/package/index.spec.ts b/lib/util/cache/package/index.spec.ts index 24f1cb5e5f47ad4505244dd0c414b382d6d985ef..65bbab5c49b58f1887671692afb1f8f50937d8b6 100644 --- a/lib/util/cache/package/index.spec.ts +++ b/lib/util/cache/package/index.spec.ts @@ -7,6 +7,9 @@ describe('util/cache/package/index', () => { it('returns undefined if not initialized', async () => { expect(await get('test', 'missing-key')).toBeUndefined(); expect(await set('test', 'some-key', 'some-value', 5)).toBeUndefined(); + expect(async () => { + await cleanup({}); + }).not.toThrow(); }); it('sets and gets file', async () => { diff --git a/lib/util/cache/package/index.ts b/lib/util/cache/package/index.ts index 9cb48a05b271b287f3d7e66fd8a0758209ed882e..438095147c78c6766a906cc0e532d9e389102b9e 100644 --- a/lib/util/cache/package/index.ts +++ b/lib/util/cache/package/index.ts @@ -4,7 +4,7 @@ import * as fileCache from './file'; import * as redisCache from './redis'; import type { PackageCache } from './types'; -let cacheProxy: PackageCache; +let cacheProxy: PackageCache | undefined; function getGlobalKey(namespace: string, key: string): string { return `global%%${namespace}%%${key}`; @@ -74,7 +74,7 @@ export async function cleanup(config: AllConfig): Promise<void> { if (config?.redisUrl) { await redisCache.end(); } - if (cacheProxy.cleanup) { + if (cacheProxy?.cleanup) { await cacheProxy.cleanup(); } }