remotion-dev/remotion · error · TypeError

CloudWatch retention period must be finite, but is ${period}

Error message

CloudWatch retention period must be finite, but is ${period}

What it means

Thrown by validateCloudWatchRetentionPeriod() (a TypeError) when the value is a non-NaN number but fails Number.isFinite() (i.e. Infinity or -Infinity). CloudWatch log retention must be a concrete day count.

Source

Thrown at packages/lambda/src/shared/validate-retention-period.ts:24

		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(
			`CloudWatch retention period must be at least ${MIN_RETENTION_PERIOD}, but is ${period}`,
		);
	}

	if (period > MAX_RETENTION_PERIOD) {
		throw new Error(

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Use Number.isFinite() to reject Infinity before calling deployFunction.
  2. Replace any 'keep forever' intent with the maximum allowed value (3650) or omit the field.
  3. Audit formulas producing the retention value for divide-by-zero cases.

Example fix

// before
const retention = totalDays / divisor  // divisor could be 0 -> Infinity
deployFunction({region, cloudWatchLogRetentionPeriodInDays: retention})
// after
const retention = Number.isFinite(totalDays / divisor) ? totalDays / divisor : undefined
deployFunction({region, cloudWatchLogRetentionPeriodInDays: retention})
Defensive patterns

Strategy: validation

Validate before calling

if (typeof period === 'number' && !Number.isFinite(period)) {
  throw new TypeError('retention must be finite')
}

Type guard

const isFiniteNumber = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v)

Prevention

When it happens

Trigger: Passing Infinity produced by dividing by zero, by Math.pow overflow, or by parsing 'Infinity' through Number().

Common situations: Computing the retention from a formula that can divide by zero; defaulting to Infinity intending 'keep forever'; JSON that contained Infinity (non-standard but Number('Infinity') works).

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/1f6511fab2a80222. Report an issue: GitHub.