remotion-dev/remotion · error · TypeError
threshold must be a number, got ${threshold} of type ${typeo
Error message
threshold must be a number, got ${threshold} of type ${typeof threshold} What it means
measureSpring's optional `threshold` (default 0.005) is the rest threshold below which the spring is considered settled. It must be a number: threshold=0 returns Infinity, threshold=1 returns 0, and any non-number throws a TypeError before the calculation runs.
Source
Thrown at packages/core/src/spring/measure-spring.ts:29
};
type MeasureSpringProps = {
fps: number;
config?: Partial<SpringConfig>;
threshold?: number;
} & (false extends typeof ENABLE_V5_BREAKING_CHANGES ? V4Props : {});
/*
* @description Based on a spring() configuration and the frame rate, return how long it takes for a spring animation to settle.
* @see [Documentation](https://remotion.dev/docs/measure-spring)
*/
export function measureSpring({
fps,
config = {},
threshold = 0.005,
}: MeasureSpringProps): number {
if (typeof threshold !== 'number') {
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');View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Pass a number: measureSpring({fps, threshold: 0.01}).
- Coerce: threshold={Number(config.threshold)}.
- Omit threshold to use the default 0.005.
Example fix
// before
measureSpring({ fps, threshold: config.threshold })
// after
measureSpring({ fps, threshold: Number(config.threshold) }) Defensive patterns
Strategy: validation
Validate before calling
const threshold = typeof raw === 'number' ? raw : Number(raw);
measureSpring({ fps, threshold }); Type guard
const isNumberThreshold = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v);
Prevention
- Pass threshold as a number literal.
- Coerce config/env-sourced values with Number() first.
- Omit threshold to use the default 0.005.
When it happens
Trigger: measureSpring({fps, threshold: "0.01"}), threshold read from JSON/env as a string, threshold from config coerced incorrectly.
Common situations: Reading threshold from a JSON config file or environment variable as a string; passing undefined implicitly; lossy type coercion.
Related errors
- HtmlInCanvas: `width` and `height` must be numbers. Received
- You passed to durationInFrames an argument of type ${typeof
- You passed to the "from" props of your <Sequence> an argumen
- Emoji ${emoji} not found. Available emojis: ${emojis.map((e)
- No id for composition passed.
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/b32a1bf7506123f0.
Report an issue: GitHub.