remotion-dev/remotion · error · TypeError

Argument passed to "${api}" for param "${param}" is ${JSON.s

Error message

Argument passed to "${api}" for param "${param}" is ${JSON.stringify(num)} (must be finite)

What it means

Third branch of `checkNumber`: the value is a `number` but fails `Number.isFinite`, i.e. it is `Infinity`, `-Infinity`, or `NaN`. The message appends `(must be finite)` and the serialized value. CSS transforms reject these values, so the helper refuses to emit them.

Source

Thrown at packages/animation-utils/src/transformation-helpers/make-transform/transform-functions.ts:41

	param: string;
	api: string;
}) => {
	if (typeof num === 'undefined') {
		throw new TypeError(
			`Argument passed to "${api}" for param "${param}" is undefined`,
		);
	}

	if (typeof num !== 'number') {
		throw new TypeError(
			`Argument passed to "${api}" for param "${param}" is ${JSON.stringify(
				num,
			)}`,
		);
	}

	if (!Number.isFinite(num)) {
		throw new TypeError(
			`Argument passed to "${api}" for param "${param}" is ${JSON.stringify(
				num,
			)} (must be finite)`,
		);
	}
};

function matrix(
	a: number,
	b: number,
	c: number,
	d: number,
	tx: number,
	ty: number,
): string {
	checkNumber({num: a, param: 'a', api: 'matrix'});
	checkNumber({num: b, param: 'b', api: 'matrix'});
	checkNumber({num: c, param: 'c', api: 'matrix'});

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Find the arithmetic that produced the non-finite value (search for division, parseInt/parseFloat, Math.log/sqrt upstream of the call).
  2. Sanitize with a guard: `const v = Number.isFinite(raw) ? raw : 0;` before calling the helper.
  3. Validate parsed input: `const n = parseFloat(s); if (!Number.isFinite(n)) return fallback;`.
  4. Clamp suspicious computed values with `Math.max/Math.min` bounds.

Example fix

// before
const angle = Math.log(progress); // NaN if progress <= 0
const r = rotate(angle);

// after
const angle = progress > 0 ? Math.log(progress) : 0;
const r = rotate(angle);
Defensive patterns

Strategy: validation

Validate before calling

// Reject non-finite numbers before they reach a transform helper.
const finiteOr = (v: unknown, fallback: number): number =>
  typeof v === 'number' && Number.isFinite(v) ? v : fallback;
// usage: translate(finiteOr(parsedX, 0))

Type guard

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

Prevention

When it happens

Trigger: Passing `Infinity` or `-Infinity` directly; passing `NaN` produced by `0/0`, `parseInt('abc')`, `Number(undefined)`, `Math.log(-1)`, or a failed `parseFloat`. Example: `translate(parseInt(userInput))` where the input is non-numeric yields `translate(NaN)`.

Common situations: Division by zero in animation math (`1 / duration` when duration is 0); `parseInt`/`parseFloat` on dirty user input that returns `NaN`; logarithmic or sqrt math on negative inputs; data feeds that occasionally deliver nulls that get coerced to 0 then divided.

Related errors


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