{"record":{"id":"c1e05c08b07f9f9e","repo":"remotion-dev/remotion","slug":"maxsize-must-be-a-number-greater-than-0","errorCode":null,"errorMessage":"`maxSize` must be a number greater than 0","messagePattern":"`maxSize` must be a number greater than 0","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/gif/src/lru/index.ts","lineNumber":85,"sourceCode":"\n\t@example\n\t```\n\timport { QuickLRU } from 'quick-lru-ts';\n\n\tconst lru = new QuickLRU({maxSize: 1000});\n\n\tlru.set('🦄', '🌈');\n\n\tlru.has('🦄');\n\t//=> true\n\n\tlru.get('🦄');\n\t//=> '🌈'\n\t```\n\t*/\n\tconstructor(options: Options<KeyType, ValueType>) {\n\t\tif (!(options.maxSize && options.maxSize > 0)) {\n\t\t\tthrow new TypeError('`maxSize` must be a number greater than 0');\n\t\t}\n\n\t\tif (typeof options.maxAge === 'number' && options.maxAge === 0) {\n\t\t\tthrow new TypeError('`maxAge` must be a number greater than 0');\n\t\t}\n\n\t\tthis.maxSize = options.maxSize;\n\t\tthis.maxAge = options.maxAge || Number.POSITIVE_INFINITY;\n\t\tthis.onEviction = options.onEviction;\n\t\tthis.cache = new Map();\n\t\tthis.oldCache = new Map();\n\t\tthis._size = 0;\n\t}\n\n\tprivate _emitEvictions(\n\t\tcache: Map<KeyType, MapValue<ValueType>> | [KeyType, MapValue<ValueType>][],\n\t) {\n\t\tif (typeof this.onEviction !== 'function') {","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/gif/src/lru/index.ts#L67-L103","documentation":"Thrown by the LRU cache constructor vendored into @remotion/gif when `options.maxSize` is falsy or not greater than zero. The cache requires a positive capacity at construction time; any value that fails `options.maxSize && options.maxSize > 0` (0, negative numbers, NaN, undefined, null) triggers this TypeError.","triggerScenarios":"Constructing `new LRUCache({maxSize: 0})`, `new LRUCache({maxSize: -1})`, `new LRUCache({maxSize: NaN})`, or omitting `maxSize` entirely. The check uses truthiness, so `0` is rejected because an empty cache is meaningless.","commonSituations":"Deriving `maxSize` from an environment variable or config that defaults to 0; passing a computed size that underflows to a negative; refactoring that drops the `maxSize` field from the options object.","solutions":["Pass a positive integer for `maxSize`, e.g. `new LRUCache({maxSize: 100})`.","If `maxSize` is dynamic, coerce and clamp it before construction: `Math.max(1, Math.floor(value))`.","Ensure the options object always includes `maxSize`."],"exampleFix":"// before\nconst cache = new LRUCache({maxSize: Number(process.env.CACHE_SIZE)});\n\n// after\nconst cache = new LRUCache({\n  maxSize: Math.max(1, Number(process.env.CACHE_SIZE) || 50),\n});","handlingStrategy":"validation","validationCode":"function makeCache(maxSize: number) {\n  if (!Number.isFinite(maxSize) || maxSize <= 0) {\n    throw new Error(`maxSize must be a positive integer, got ${maxSize}`);\n  }\n  return new LRUCache({maxSize: Math.floor(maxSize)});\n}","typeGuard":"function isValidMaxSize(value: unknown): value is number {\n  return typeof value === 'number' && Number.isFinite(value) && value > 0;\n}","tryCatchPattern":null,"preventionTips":["Always pass an explicit positive integer for maxSize when constructing the cache.","Clamp environment/config-derived sizes with Math.max(1, ...) before construction.","Treat a default of 0 as a config bug, not as 'unlimited'."],"tags":["cache","validation","lru","constructor"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}