diff --git a/packages/core/src/utils/LruCache.ts b/packages/core/src/utils/LruCache.ts index 076828c459..9780b85af7 100644 --- a/packages/core/src/utils/LruCache.ts +++ b/packages/core/src/utils/LruCache.ts @@ -14,12 +14,13 @@ export class LruCache { } get(key: K): V | undefined { - const value = this.cache.get(key); - if (value) { - // Move to end to mark as recently used - this.cache.delete(key); - this.cache.set(key, value); + if (!this.cache.has(key)) { + return undefined; } + const value = this.cache.get(key) as V; + // Move to end to mark as recently used + this.cache.delete(key); + this.cache.set(key, value); return value; }