remotion-dev/remotion · error · TypeError
maxRetries must be finite, but is ${maxRetries}
Error message
maxRetries must be finite, but is ${maxRetries} What it means
Thrown by validateMaxRetries() when maxRetries is a number but fails Number.isFinite(), i.e. it is Infinity or -Infinity. This guard sits between the type check and the NaN check, and because Number.isFinite(NaN) is also false, a NaN value will hit this branch (rendered as '...must be finite, but is NaN') rather than the dedicated NaN branch below it.
Source
Thrown at packages/cloudrun/src/shared/validate-retries.ts:11
export function validateMaxRetries(
maxRetries: unknown,
): asserts maxRetries is number {
if (typeof maxRetries !== 'number') {
throw new TypeError(
'maxRetries must be a number, but is ' + JSON.stringify(maxRetries),
);
}
if (!Number.isFinite(maxRetries)) {
throw new TypeError('maxRetries must be finite, but is ' + maxRetries);
}
if (Number.isNaN(maxRetries)) {
throw new TypeError('maxRetries is NaN');
}
if (maxRetries < 0) {
throw new TypeError(`maxRetries cannot be negative but is ${maxRetries}`);
}
if (maxRetries % 1 !== 0) {
throw new TypeError(
`maxRetries should be an integer, but is ${maxRetries}.`,
);
}
}
View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Validate with Number.isFinite() and substitute a sane default (e.g. 1) before calling the API.
- Trace the source of the value: confirm the arithmetic producing maxRetries never divides by zero or operates on undefined.
- If the value is user-supplied, reject non-finite input in your own validation layer.
Example fix
// before const maxRetries = total / shards; // shards could be 0 -> Infinity // after const maxRetries = Number.isFinite(total / shards) ? total / shards : 1;
Defensive patterns
Strategy: validation
Validate before calling
if (!Number.isFinite(maxRetries)) {
throw new RangeError('maxRetries must be a finite number');
} Type guard
const isFiniteNumber = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v);
Prevention
- Coerce untrusted input with Number() then guard with Number.isFinite() before use.
- Avoid arithmetic that can divide by zero when computing retry counts.
- Provide a numeric fallback whenever the source value is optional.
When it happens
Trigger: Passing Infinity, -Infinity, or NaN as maxRetries. NaN typically arrives from arithmetic on undefined (e.g. Number(undefined) is NaN) or a failed Number() coercion; Infinity can come from division by zero or explicit constants.
Common situations: Computing retries from a formula that divides by a zero/undefined denominator; using Number(maybeUndefined) without a fallback; parsing user input that is empty and coerces to NaN.
Related errors
- 'bucketName' must be a string, but is ${JSON.stringify(bucke
- "cloudRunUrl" parameter must be a string, but is ${JSON.stri
- "codec" must be a string
- Privacy must be a string
- The 'project-id' argument must be a string, but is ${JSON.st
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/ec85834b612aa744.
Report an issue: GitHub.