diff --git a/src/services/diskLRU.ts b/src/services/diskLRU.ts index 5aa133a41..56f0e9593 100644 --- a/src/services/diskLRU.ts +++ b/src/services/diskLRU.ts @@ -53,8 +53,19 @@ class DiskLRUService { if (size >= maxSize) { const leastRecentlyUsed = await this.findLeastRecentlyUsed(cacheDir); - - await unlink(leastRecentlyUsed.path); + try { + await unlink(leastRecentlyUsed.path); + } catch (e) { + // ENOENT: File not found + // which can be ignored as we are trying to delete the file anyway + if (e.code !== 'ENOENT') { + logError( + e, + 'Failed to evict least recently used' + ); + } + // ignoring the error, as it would get retried on the next run + } this.evictLeastRecentlyUsed(cacheDir, maxSize); } resolve(null);