{"record":{"id":"8ce19063717dc6bc","repo":"remotion-dev/remotion","slug":"maxage-must-be-a-number-greater-than-0","errorCode":null,"errorMessage":"`maxAge` must be a number greater than 0","messagePattern":"`maxAge` must be a number greater than 0","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/gif/src/lru/index.ts","lineNumber":89,"sourceCode":"\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') {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const [key, item] of cache) {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/gif/src/lru/index.ts#L71-L107","documentation":"Thrown by the LRU cache constructor when `options.maxAge` is explicitly the number `0`. A max-age of zero would expire entries immediately, which is treated as a configuration mistake. Note that omitting `maxAge` is fine (it defaults to Infinity), and any other positive number is accepted; only the literal value `0` typed as a number is rejected.","triggerScenarios":"Constructing `new LRUCache({maxSize: 10, maxAge: 0})`. The guard is `typeof options.maxAge === 'number' && options.maxAge === 0`, so `undefined`, `null`, or a positive number all pass.","commonSituations":"Setting `maxAge` from a config where a default of 0 leaks in; computing `maxAge` from a millisecond delta that resolves to 0; misunderstanding that 0 means 'no expiry' in some other libraries.","solutions":["Pass a positive number of milliseconds for `maxAge`, e.g. `maxAge: 60_000`.","If you want no age-based eviction, omit `maxAge` entirely rather than setting it to 0.","Coerce dynamic values: `maxAge: value > 0 ? value : undefined`."],"exampleFix":"// before\nnew LRUCache({maxSize: 10, maxAge: 0});\n\n// after\nnew LRUCache({maxSize: 10, maxAge: 60_000});","handlingStrategy":"validation","validationCode":"function resolveMaxAge(value: number | undefined): number | undefined {\n  if (value === undefined) return undefined; // no age-based eviction\n  if (!Number.isFinite(value) || value <= 0) {\n    throw new Error(`maxAge must be a positive number of ms, got ${value}`);\n  }\n  return value;\n}","typeGuard":"function isValidMaxAge(value: unknown): boolean {\n  return value === undefined || (typeof value === 'number' && Number.isFinite(value) && value > 0);\n}","tryCatchPattern":null,"preventionTips":["Omit maxAge entirely if you do not want age-based eviction.","Never default maxAge to 0; treat 0 as 'misconfigured'.","Express maxAge in milliseconds and validate it is positive."],"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"}