remotion-dev/remotion · error · TypeError
Threshold is not finite
Error message
Threshold is not finite
What it means
measureSpring()'s `threshold` option must be a finite positive number. Because `threshold === 0` short-circuits to `Infinity` earlier, this guard specifically catches a user-supplied `Infinity` or `-Infinity`. An infinite threshold would make the settling loop terminate instantly (or never compare correctly), producing a meaningless duration.
Source
Thrown at packages/core/src/spring/measure-spring.ts:47
throw new TypeError(
`threshold must be a number, got ${threshold} of type ${typeof threshold}`,
);
}
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)!;
}
View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Pass a small finite positive number such as 0.005, or omit threshold to use the default.
- Validate with `Number.isFinite(threshold)` before calling measureSpring().
- Clamp the computed threshold, e.g. `Math.min(Math.max(t, 1e-6), 1)`.
Example fix
// before
const dur = measureSpring({fps: 30, threshold: someRatio / divisor});
// after
const raw = someRatio / divisor;
const threshold = Number.isFinite(raw) && raw > 0 ? raw : 0.005;
const dur = measureSpring({fps: 30, threshold}); Defensive patterns
Strategy: validation
Validate before calling
const threshold = computeThreshold();
if (!Number.isFinite(threshold)) {
throw new Error(`threshold must be finite, got ${threshold}`);
}
const dur = measureSpring({fps: 30, threshold}); Type guard
const isFiniteThreshold = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v);
Prevention
- Clamp computed thresholds: `Math.min(Math.max(t, 1e-6), 1)`.
- Avoid expressions that can overflow (1/x with x near 0, Math.exp of large numbers).
- Treat threshold as a bounded configuration value, not a derived metric.
When it happens
Trigger: Calling `measureSpring({fps, threshold: Infinity})` or passing a computed threshold that overflowed to Infinity, e.g. `1/0`, `Number.MAX_VALUE * 2`, or `Math.exp(1000)`.
Common situations: Math expressions that can overflow; copying a value from a slider or config that allows unbounded inputs.
Related errors
- Threshold is NaN
- Threshold is below 0
- Spring damping must be greater than 0, otherwise the spring(
- A "duration" of a spring must be a "number" but is "${typeof
- A "duration" of a spring is NaN, which it must not be
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/b307359d3c3f970b.
Report an issue: GitHub.