Skip to content

Commit

Permalink
wrap with guard block
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian "Sebbie" Silbermann <sebastian.silbermann@vercel.com>
  • Loading branch information
devjiwonchoi and eps1lon committed Nov 5, 2024
1 parent acd9aef commit 444895b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/next/src/server/lib/lru-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ export class LRUCache<T> {
}

private evictLeastRecentlyUsed(): void {
const lruKey = this.cache.keys().next().value || ''
const lruSize = this.sizes.get(lruKey) || 0
this.totalSize -= lruSize
this.cache.delete(lruKey)
this.sizes.delete(lruKey)
const lruKey = this.cache.keys().next().value
if (lruKey !== undefined) {
const lruSize = this.sizes.get(lruKey) || 0
this.totalSize -= lruSize
this.cache.delete(lruKey)
this.sizes.delete(lruKey)
}
}

reset() {
Expand Down

0 comments on commit 444895b

Please sign in to comment.