remotion-dev/remotion · error · TypeError

Threshold is below 0

Error message

Threshold is below 0

What it means

measureSpring()'s `threshold` represents the maximum distance from the target value at which the spring is considered settled, so it must be non-negative. This guard rejects any negative threshold, which would never be satisfied by an absolute difference and would loop forever.

Source

Thrown at packages/core/src/spring/measure-spring.ts:51

	if (threshold === 0) {
		return Infinity;
	}

	if (threshold === 1) {
		return 0;
	}

	if (isNaN(threshold)) {
		throw new TypeError('Threshold is NaN');
	}

	if (!Number.isFinite(threshold)) {
		throw new TypeError('Threshold is not finite');
	}

	if (threshold < 0) {
		throw new TypeError('Threshold is below 0');
	}

	const cacheKey = [
		fps,
		config.damping,
		config.mass,
		config.overshootClamping,
		config.stiffness,
		threshold,
	].join('-');
	if (cache.has(cacheKey)) {
		return cache.get(cacheKey)!;
	}

	validateFps(fps, 'to the measureSpring() function', false);

	let frame = 0;
	let finishedFrame = 0;

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Pass a positive threshold (typical values are between 0 and 1, e.g. 0.005).
  2. Wrap computed thresholds with `Math.abs(...)` before passing.
  3. Validate `threshold >= 0` before calling measureSpring().

Example fix

// before
const dur = measureSpring({fps: 30, threshold: target - current});

// after
const dur = measureSpring({fps: 30, threshold: Math.abs(target - current)});
Defensive patterns

Strategy: validation

Validate before calling

const threshold = computeThreshold();
if (typeof threshold !== 'number' || threshold < 0) {
  throw new Error(`threshold must be >= 0, got ${threshold}`);
}
const dur = measureSpring({fps: 30, threshold});

Type guard

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

Prevention

When it happens

Trigger: Calling `measureSpring({fps, threshold: -0.1})` or passing a computed threshold that went negative, e.g. `a - b` where `a < b`, or a sign error in configuration.

Common situations: Off-by-one or sign mistakes when deriving threshold from offsets; reusing a 'tolerance' variable that holds a signed delta.

Related errors


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