remotion-dev/remotion · error · TypeError
CloudWatch retention period must be an integer, but is NaN
Error message
CloudWatch retention period must be an integer, but is NaN
What it means
Thrown by validateCloudWatchRetentionPeriod() (a TypeError) when the value is a number but is NaN. This typically results from Number('') or Number('not-a-number') coercion producing NaN, which would otherwise pass the typeof number check.
Source
Thrown at packages/lambda/src/shared/validate-retention-period.ts:18
const MIN_RETENTION_PERIOD = 1;
const MAX_RETENTION_PERIOD = 10 * 365;
export const validateCloudWatchRetentionPeriod = (period: unknown) => {
if (period === null || period === undefined) {
return;
}
if (typeof period !== 'number') {
throw new TypeError(
`CloudWatch retention period should be a number, got: ${JSON.stringify(
period,
)}`,
);
}
if (Number.isNaN(period)) {
throw new TypeError(
`CloudWatch retention period must be an integer, but is NaN`,
);
}
if (!Number.isFinite(period)) {
throw new TypeError(
`CloudWatch retention period must be finite, but is ${period}`,
);
}
if (period % 1 !== 0) {
throw new TypeError(
`CloudWatch retention period must be an integer, but is ${period}`,
);
}
if (period < MIN_RETENTION_PERIOD) {
throw new Error(View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Guard parsing: only convert when the source string is non-empty and numeric.
- Use Number.isFinite() on the parsed value before passing it through.
- Omit the field (undefined) when no value is configured.
Example fix
// before
const retention = Number(process.env.RETENTION) // '' -> NaN
deployFunction({region, cloudWatchLogRetentionPeriodInDays: retention})
// after
const raw = process.env.RETENTION
const retention = raw && /^\d+$/.test(raw) ? Number(raw) : undefined
deployFunction({region, cloudWatchLogRetentionPeriodInDays: retention}) Defensive patterns
Strategy: validation
Validate before calling
if (typeof period === 'number' && Number.isNaN(period)) {
throw new TypeError('retention parsed to NaN; check the source string')
} Type guard
const isFiniteNumber = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v)
Prevention
- Parse env values with a strict numeric regex before Number().
- Treat empty env strings as 'unset' rather than Number('').
- Centralise numeric config parsing in one helper.
When it happens
Trigger: Passing Number('') or Number('abc') as the retention period; arithmetic on undefined that yields NaN; parsing an empty env var with Number().
Common situations: Env var empty/unset but coerced with Number() instead of conditional parsing; config typos parsed as NaN; defaulting to a numeric operation that produces NaN.
Related errors
- CloudWatch retention period should be a number, got: ${JSON.
- A custom role ARN must either be "undefined" or a string, bu
- CloudWatch retention period must be finite, but is ${period}
- CloudWatch retention period must be an integer, but is ${per
- CloudWatch retention period must be at least ${MIN_RETENTION
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/a586fd9e92366718.
Report an issue: GitHub.