{"record":{"id":"b32a1bf7506123f0","repo":"remotion-dev/remotion","slug":"threshold-must-be-a-number-got-threshold-of-ty","errorCode":null,"errorMessage":"threshold must be a number, got ${threshold} of type ${typeof threshold}","messagePattern":"threshold must be a number, got (.+?) of type (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/spring/measure-spring.ts","lineNumber":29,"sourceCode":"};\n\ntype MeasureSpringProps = {\n\tfps: number;\n\tconfig?: Partial<SpringConfig>;\n\tthreshold?: number;\n} & (false extends typeof ENABLE_V5_BREAKING_CHANGES ? V4Props : {});\n\n/*\n * @description Based on a spring() configuration and the frame rate, return how long it takes for a spring animation to settle.\n * @see [Documentation](https://remotion.dev/docs/measure-spring)\n */\nexport function measureSpring({\n\tfps,\n\tconfig = {},\n\tthreshold = 0.005,\n}: MeasureSpringProps): number {\n\tif (typeof threshold !== 'number') {\n\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');","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/spring/measure-spring.ts#L11-L47","documentation":"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.","triggerScenarios":"measureSpring({fps, threshold: \"0.01\"}), threshold read from JSON/env as a string, threshold from config coerced incorrectly.","commonSituations":"Reading threshold from a JSON config file or environment variable as a string; passing undefined implicitly; lossy type coercion.","solutions":["Pass a number: measureSpring({fps, threshold: 0.01}).","Coerce: threshold={Number(config.threshold)}.","Omit threshold to use the default 0.005."],"exampleFix":"// before\nmeasureSpring({ fps, threshold: config.threshold })\n// after\nmeasureSpring({ fps, threshold: Number(config.threshold) })","handlingStrategy":"validation","validationCode":"const threshold = typeof raw === 'number' ? raw : Number(raw);\nmeasureSpring({ fps, threshold });","typeGuard":"const isNumberThreshold = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isFinite(v);","tryCatchPattern":null,"preventionTips":["Pass threshold as a number literal.","Coerce config/env-sourced values with Number() first.","Omit threshold to use the default 0.005."],"tags":["spring","validation","props","types"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}