remotion-dev/remotion · error · TypeError
maxRetries is NaN
Error message
maxRetries is NaN
What it means
Intended to be thrown by validateMaxRetries() when maxRetries is NaN. In practice this branch is effectively unreachable: the preceding Number.isFinite() check (line 10) is also false for NaN, so a NaN value is caught first by the 'must be finite' error at line 11 which reports 'must be finite, but is NaN'. If you ever see the literal text 'maxRetries is NaN', the validator's check order has changed.
Source
Thrown at packages/cloudrun/src/shared/validate-retries.ts:15
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
- Guard the input with Number.isFinite() before calling the API, which also rejects NaN.
- Provide an explicit numeric default whenever the source value is optional or untrusted.
- If you need to distinguish NaN specifically, check Number.isNaN() in your own layer first.
Example fix
// before
renderMediaOnCloudRun({ ...opts, maxRetries: Number(input.retries) });
// after
const parsed = Number(input.retries);
const maxRetries = Number.isFinite(parsed) ? parsed : 1;
renderMediaOnCloudRun({ ...opts, maxRetries }); Defensive patterns
Strategy: validation
Validate before calling
if (typeof maxRetries === 'number' && Number.isNaN(maxRetries)) {
throw new TypeError('maxRetries is NaN');
} Type guard
const isNonNaNNumber = (v: unknown): v is number => typeof v === 'number' && !Number.isNaN(v);
Prevention
- Use Number.isFinite() upstream - it rejects NaN, Infinity, and non-numbers in one check.
- Do not call Number() on empty or non-numeric strings without a fallback.
- Note: in the current validator order NaN is actually caught by the 'must be finite' guard first.
When it happens
Trigger: Passing NaN as maxRetries (e.g. Number(undefined) or Number('abc')). In the current code path the observable error is the 'must be finite' message, not this one.
Common situations: Empty or non-numeric user input coerced with Number(); arithmetic on undefined values; defaulting that accidentally yields NaN.
Related errors
- maxRetries must be finite, but is ${maxRetries}
- maxRetries cannot be negative but is ${maxRetries}
- maxRetries should be an integer, but is ${maxRetries}.
- Bucket creation is required, but no region has been passed.
- Either cloudRunUrl or serviceName must be provided
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/76d4c2a4a1331a36.
Report an issue: GitHub.