remotion-dev/remotion · error · TypeError

A "duration" of a spring must be finite, but is ${dur}

Error message

A "duration" of a spring must be finite, but is ${dur}

What it means

`validateSpringDuration()` rejects non-finite numbers (Infinity/-Infinity) for the optional `duration`. A non-finite duration would cause spring math to never converge, so the validator stops it early.

Source

Thrown at packages/core/src/validation/validation-spring-duration.ts:19

export const validateSpringDuration = (dur: unknown) => {
	if (typeof dur === 'undefined') {
		return;
	}

	if (typeof dur !== 'number') {
		throw new TypeError(
			`A "duration" of a spring must be a "number" but is "${typeof dur}"`,
		);
	}

	if (Number.isNaN(dur)) {
		throw new TypeError(
			'A "duration" of a spring is NaN, which it must not be',
		);
	}

	if (!Number.isFinite(dur)) {
		throw new TypeError(
			'A "duration" of a spring must be finite, but is ' + dur,
		);
	}

	if (dur <= 0) {
		throw new TypeError(
			'A "duration" of a spring must be positive, but is ' + dur,
		);
	}
};

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Pass a finite, positive number of seconds.
  2. Clamp the computed value: `duration: Math.min(10, Math.max(0.1, computed))`.
  3. Audit the arithmetic upstream of the spring call.

Example fix

// before
spring({frame, fps, config, duration: 1 / ratio}); // Infinity when ratio=0
// after
const duration = Number.isFinite(1 / ratio) ? 1 / ratio : 1;
spring({frame, fps, config, duration});
Defensive patterns

Strategy: validation

Validate before calling

const duration = Number.isFinite(rawDuration) ? rawDuration : 1;

Type guard

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

Prevention

When it happens

Trigger: Passing `duration: Infinity` or a value produced by an overflowing expression such as `1 / 0` to `spring()`.

Common situations: Computing duration as a ratio that can divide by zero, or accepting user input that includes division expressions.

Related errors


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