{"record":{"id":"8eaf25a448e42638","repo":"vercel/next.js","slug":"single-item-size-exceeds-maxsize","errorCode":null,"errorMessage":"Single item size exceeds maxSize","messagePattern":"Single item size exceeds maxSize","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/lib/lru-cache.ts","lineNumber":137,"sourceCode":"  /**\n   * Sets a key-value pair in the cache.\n   * If the key exists, updates the value and moves to head.\n   * If new, adds at head and evicts from tail if necessary.\n   *\n   * Time Complexity:\n   * - O(1) for uniform item sizes\n   * - O(k) where k is the number of items evicted (can be O(N) for variable sizes)\n   */\n  public set(key: string, value: T): boolean {\n    const size = this.calculateSize?.(value, key) ?? 1\n    if (size <= 0) {\n      throw new Error(\n        `LRUCache: calculateSize returned ${size}, but size must be > 0. ` +\n          `Items with size 0 would never be evicted, causing unbounded cache growth.`\n      )\n    }\n    if (size > this.maxSize) {\n      console.warn('Single item size exceeds maxSize')\n      return false\n    }\n\n    const existing = this.cache.get(key)\n    if (existing) {\n      // Update existing node: adjust size and move to head (most recent)\n      existing.data = value\n      this.totalSize = this.totalSize - existing.size + size\n      existing.size = size\n      this.moveToHead(existing)\n    } else {\n      // Add new node at head (most recent position)\n      const newNode = new LRUNode(key, value, size)\n      this.cache.set(key, newNode)\n      this.addToHead(newNode)\n      this.totalSize += size\n    }\n","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/server/lib/lru-cache.ts#L119-L155","documentation":"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.","triggerScenarios":"Thrown at packages/next/src/server/lib/lru-cache.ts:137 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the cached item size below the configured maxSize, or raise the LRU cache maxSize."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eb377541648e63402a47b38fee00a8d0ce8f8f1","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}