vercel/next.js · error
Single item size exceeds maxSize
Error message
Single item size exceeds maxSize
What it means
LRUCache.set computes the item size via calculateSize (defaulting to 1) and throws when a single item's size exceeds the cache's total maxSize, because such an entry could never fit; callers must raise maxSize or store a smaller value.
Source
Thrown at packages/next/src/server/lib/lru-cache.ts:137
/**
* Sets a key-value pair in the cache.
* If the key exists, updates the value and moves to head.
* If new, adds at head and evicts from tail if necessary.
*
* Time Complexity:
* - O(1) for uniform item sizes
* - O(k) where k is the number of items evicted (can be O(N) for variable sizes)
*/
public set(key: string, value: T): boolean {
const size = this.calculateSize?.(value, key) ?? 1
if (size <= 0) {
throw new Error(
`LRUCache: calculateSize returned ${size}, but size must be > 0. ` +
`Items with size 0 would never be evicted, causing unbounded cache growth.`
)
}
if (size > this.maxSize) {
console.warn('Single item size exceeds maxSize')
return false
}
const existing = this.cache.get(key)
if (existing) {
// Update existing node: adjust size and move to head (most recent)
existing.data = value
this.totalSize = this.totalSize - existing.size + size
existing.size = size
this.moveToHead(existing)
} else {
// Add new node at head (most recent position)
const newNode = new LRUNode(key, value, size)
this.cache.set(key, newNode)
this.addToHead(newNode)
this.totalSize += size
}
View on GitHub (pinned to 0eb3775416)
Solutions
- Reduce the cached item size below the configured maxSize, or raise the LRU cache maxSize.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/next/src/server/lib/lru-cache.ts:137 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19).
Data as JSON: /api/errors/8eaf25a448e42638.
Report an issue: GitHub.