remotion-dev/remotion · error · TypeError

Parameter 'durationInMilliseconds' must be over 0 but it is

Error message

Parameter 'durationInMilliseconds' must be over 0 but it is ${durationInMilliseconds}.

What it means

Final guard in the estimatePrice validation chain: durationInMilliseconds < 0 throws a TypeError. A negative duration is nonsensical for a price estimate.

Source

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

		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;

	// In GB-second
	const timeCostDollars =
		Number(durationPrice) *
		((memorySizeInMb * durationInMilliseconds) / 1000 / 1024);

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

	const chargedDiskSize = Math.max(
		0,
		diskSizeInMb - MIN_EPHEMERAL_STORAGE_IN_MB,
	);
	// In GB-second

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Clamp durationInMilliseconds to >= 0 (Math.max(0, value)) before calling
  2. Fix the upstream subtraction that produced a negative duration

Example fix

// before
const durationInMilliseconds = end - start; // reversed -> negative

// after
const durationInMilliseconds = Math.max(0, start - end);
Defensive patterns

Strategy: validation

Validate before calling

const durationInMilliseconds = Math.max(0, start - end);

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 a finite number but negative (e.g. a clock skew or a subtraction that went below zero).

Common situations: Negative duration from end-start math with reversed operands, bad default value of -1, sign error.

Related errors


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