remotion-dev/remotion · error · TypeError

Parameter 'durationInMilliseconds' must not be NaN but it is

Error message

Parameter 'durationInMilliseconds' must not be NaN but it is.

What it means

Second guard in the estimatePrice validation chain: after the typeof check passes, Number.isNaN(durationInMilliseconds) is evaluated and a TypeError is thrown if true. This catches NaN that arises from bad arithmetic upstream (e.g. Number(undefined) is NaN but typeof kept it a number is impossible here — more commonly parseFloat failures passed through as number).

Source

Thrown at packages/lambda-client/src/estimate-price.ts:53

	...other
}: EstimatePriceInput): number => {
	validateMemorySize(memorySizeInMb);
	validateAwsRegion(region);
	validateDiskSizeInMb(diskSizeInMb);

	const durationInMilliseconds =
		'durationInMiliseconds' in other
			? other.durationInMiliseconds
			: other.durationInMilliseconds;

	if (typeof durationInMilliseconds !== 'number') {
		throw new TypeError(
			`Parameter 'durationInMilliseconds' must be a number but got ${typeof durationInMilliseconds}`,
		);
	}

	if (Number.isNaN(durationInMilliseconds)) {
		throw new TypeError(
			`Parameter 'durationInMilliseconds' must not be NaN but it is.`,
		);
	}

	if (!Number.isFinite(durationInMilliseconds)) {
		throw new TypeError(
			`Parameter 'durationInMilliseconds' must be finite but it is ${durationInMilliseconds}`,
		);
	}

	if (durationInMilliseconds < 0) {
		throw new TypeError(
			`Parameter 'durationInMilliseconds' must be over 0 but it is ${durationInMilliseconds}.`,
		);
	}

	const durationPrice = pricing[region]['Lambda Duration-ARM'].price;

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Validate the source of durationInMilliseconds with Number.isFinite before calling estimatePrice
  2. Guard parseFloat results with Number.isNaN and reject early

Example fix

// before
const durationInMilliseconds = parseFloat(input);
estimatePrice({ ..., durationInMilliseconds });

// after
const durationInMilliseconds = Number(input);
if (!Number.isFinite(durationInMilliseconds)) throw new Error('bad duration');
estimatePrice({ ..., durationInMilliseconds });
Defensive patterns

Strategy: validation

Validate before calling

const durationInMilliseconds = Number(input);
if (Number.isNaN(durationInMilliseconds)) {
  throw new Error('duration input is not numeric');
}
estimatePrice({ ..., durationInMilliseconds });

Type guard

const isDuration = (v: unknown): v is number => typeof v === 'number' && !Number.isNaN(v) && Number.isFinite(v) && v >= 0;

Prevention

When it happens

Trigger: durationInMilliseconds is the literal NaN value (e.g. produced by parseFloat('abc') or 0/0).

Common situations: Parsing user input with parseFloat without checking for NaN, downstream arithmetic that produced NaN.

Related errors


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