remotion-dev/remotion · error · TypeError
maxRetries cannot be negative but is ${maxRetries}
Error message
maxRetries cannot be negative but is ${maxRetries} What it means
Thrown by validateMaxRetries() when maxRetries is a finite number but is less than 0. Retries cannot be negative, so the validator rejects any negative value after confirming type, finiteness, and non-NaN.
Source
Thrown at packages/cloudrun/src/shared/validate-retries.ts:19
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
- Clamp the value to a minimum of 0: Math.max(0, value).
- Re-check the arithmetic that produces maxRetries for an inverted subtraction.
- Use a literal (0 is valid) when you want to disable retries.
Example fix
// before const maxRetries = current - budget; // can be negative // after const maxRetries = Math.max(0, current - budget);
Defensive patterns
Strategy: validation
Validate before calling
if (typeof maxRetries === 'number' && maxRetries < 0) {
throw new RangeError(`maxRetries cannot be negative: ${maxRetries}`);
} Type guard
const isNonNegativeInt = (v: unknown): v is number => typeof v === 'number' && Number.isInteger(v) && v >= 0;
Prevention
- Clamp computed retry counts with Math.max(0, value).
- Double-check subtraction/difference expressions that derive retries.
- Use 0 to explicitly disable retries rather than a negative sentinel.
When it happens
Trigger: Passing a negative retry count, often the result of subtracting a larger number from a smaller one, or flipping a sign incorrectly.
Common situations: Computing retries as a difference (e.g. attempt - maxAttempts) that goes negative; off-by-one in a decrement loop; user input parsed with an erroneous minus sign.
Related errors
- maxRetries must be finite, but is ${maxRetries}
- maxRetries is NaN
- 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/310b92df77217569.
Report an issue: GitHub.