remotion-dev/remotion · error · TypeError

A "duration" of a spring must be a "number" but is "${typeof

Error message

A "duration" of a spring must be a "number" but is "${typeof dur}"

What it means

`validateSpringDuration()` guards the optional `duration` option of Remotion's `spring()` animation helper. This branch fires when `duration` is defined (not `undefined`) but is not a `number`. The message reports the actual typeof so you can identify string/object leaks.

Source

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

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(

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Pass `duration` as a number (seconds), e.g. `duration: 1`.
  2. Omit `duration` entirely if you don't need it (the function returns early when `undefined`).
  3. Coerce from input: `duration: Number(rawDuration)`.

Example fix

// before
spring({frame, fps, config, duration: '1'});
// after
spring({frame, fps, config, duration: 1});
Defensive patterns

Strategy: validation

Validate before calling

function safeDuration(d: unknown): number | undefined {
  if (d == null) return undefined;
  if (typeof d !== 'number') throw new TypeError('duration must be a number');
  return d;
}

Type guard

const isOptionalNumber = (v: unknown): v is number | undefined => v == null || typeof v === 'number';

Prevention

When it happens

Trigger: Calling `spring({frame, fps, config, duration: '1s'})` or passing a non-numeric `duration` from a prop, state, or deserialized config.

Common situations: Authoring spring config from form input or props where duration is a string like `"1"`, or destructuring a config object that accidentally carries a stringified value.

Related errors


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