remotion-dev/remotion · error · TypeError
`maxAge` must be a number greater than 0
Error message
`maxAge` must be a number greater than 0
What it means
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.
Source
Thrown at packages/gif/src/lru/index.ts:89
const lru = new QuickLRU({maxSize: 1000});
lru.set('🦄', '🌈');
lru.has('🦄');
//=> true
lru.get('🦄');
//=> '🌈'
```
*/
constructor(options: Options<KeyType, ValueType>) {
if (!(options.maxSize && options.maxSize > 0)) {
throw new TypeError('`maxSize` must be a number greater than 0');
}
if (typeof options.maxAge === 'number' && options.maxAge === 0) {
throw new TypeError('`maxAge` must be a number greater than 0');
}
this.maxSize = options.maxSize;
this.maxAge = options.maxAge || Number.POSITIVE_INFINITY;
this.onEviction = options.onEviction;
this.cache = new Map();
this.oldCache = new Map();
this._size = 0;
}
private _emitEvictions(
cache: Map<KeyType, MapValue<ValueType>> | [KeyType, MapValue<ValueType>][],
) {
if (typeof this.onEviction !== 'function') {
return;
}
for (const [key, item] of cache) {View on GitHub (pinned to 78fe4bb3fd)
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`.
Example fix
// before
new LRUCache({maxSize: 10, maxAge: 0});
// after
new LRUCache({maxSize: 10, maxAge: 60_000}); Defensive patterns
Strategy: validation
Validate before calling
function resolveMaxAge(value: number | undefined): number | undefined {
if (value === undefined) return undefined; // no age-based eviction
if (!Number.isFinite(value) || value <= 0) {
throw new Error(`maxAge must be a positive number of ms, got ${value}`);
}
return value;
} Type guard
function isValidMaxAge(value: unknown): boolean {
return value === undefined || (typeof value === 'number' && Number.isFinite(value) && value > 0);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- `maxSize` must be a number greater than 0
- 'region' parameter is required and cannot be empty or whites
- 'serve_url' parameter is required and cannot be empty or whi
- 'function_name' parameter is required and cannot be empty or
- Emoji ${emoji} not found. Available emojis: ${emojis.map((e)
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/8ce19063717dc6bc.
Report an issue: GitHub.