{"record":{"id":"b307359d3c3f970b","repo":"remotion-dev/remotion","slug":"threshold-is-not-finite","errorCode":null,"errorMessage":"Threshold is not finite","messagePattern":"Threshold is not finite","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/spring/measure-spring.ts","lineNumber":47,"sourceCode":"\t\tthrow new TypeError(\n\t\t\t`threshold must be a number, got ${threshold} of type ${typeof threshold}`,\n\t\t);\n\t}\n\n\tif (threshold === 0) {\n\t\treturn Infinity;\n\t}\n\n\tif (threshold === 1) {\n\t\treturn 0;\n\t}\n\n\tif (isNaN(threshold)) {\n\t\tthrow new TypeError('Threshold is NaN');\n\t}\n\n\tif (!Number.isFinite(threshold)) {\n\t\tthrow new TypeError('Threshold is not finite');\n\t}\n\n\tif (threshold < 0) {\n\t\tthrow new TypeError('Threshold is below 0');\n\t}\n\n\tconst cacheKey = [\n\t\tfps,\n\t\tconfig.damping,\n\t\tconfig.mass,\n\t\tconfig.overshootClamping,\n\t\tconfig.stiffness,\n\t\tthreshold,\n\t].join('-');\n\tif (cache.has(cacheKey)) {\n\t\treturn cache.get(cacheKey)!;\n\t}\n","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/spring/measure-spring.ts#L29-L65","documentation":"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.","triggerScenarios":"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)`.","commonSituations":"Math expressions that can overflow; copying a value from a slider or config that allows unbounded inputs.","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)`."],"exampleFix":"// before\nconst dur = measureSpring({fps: 30, threshold: someRatio / divisor});\n\n// after\nconst raw = someRatio / divisor;\nconst threshold = Number.isFinite(raw) && raw > 0 ? raw : 0.005;\nconst dur = measureSpring({fps: 30, threshold});","handlingStrategy":"validation","validationCode":"const threshold = computeThreshold();\nif (!Number.isFinite(threshold)) {\n  throw new Error(`threshold must be finite, got ${threshold}`);\n}\nconst dur = measureSpring({fps: 30, threshold});","typeGuard":"const isFiniteThreshold = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isFinite(v);","tryCatchPattern":null,"preventionTips":["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."],"tags":["spring","animation","infinity","validation","measure-spring"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}