{"record":{"id":"b9153ed95fe5f188","repo":"remotion-dev/remotion","slug":"parameter-durationinmilliseconds-must-not-be-nan","errorCode":null,"errorMessage":"Parameter 'durationInMilliseconds' must not be NaN but it is.","messagePattern":"Parameter 'durationInMilliseconds' must not be NaN but it is\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/lambda-client/src/estimate-price.ts","lineNumber":53,"sourceCode":"\t...other\n}: EstimatePriceInput): number => {\n\tvalidateMemorySize(memorySizeInMb);\n\tvalidateAwsRegion(region);\n\tvalidateDiskSizeInMb(diskSizeInMb);\n\n\tconst durationInMilliseconds =\n\t\t'durationInMiliseconds' in other\n\t\t\t? other.durationInMiliseconds\n\t\t\t: other.durationInMilliseconds;\n\n\tif (typeof durationInMilliseconds !== 'number') {\n\t\tthrow new TypeError(\n\t\t\t`Parameter 'durationInMilliseconds' must be a number but got ${typeof durationInMilliseconds}`,\n\t\t);\n\t}\n\n\tif (Number.isNaN(durationInMilliseconds)) {\n\t\tthrow new TypeError(\n\t\t\t`Parameter 'durationInMilliseconds' must not be NaN but it is.`,\n\t\t);\n\t}\n\n\tif (!Number.isFinite(durationInMilliseconds)) {\n\t\tthrow new TypeError(\n\t\t\t`Parameter 'durationInMilliseconds' must be finite but it is ${durationInMilliseconds}`,\n\t\t);\n\t}\n\n\tif (durationInMilliseconds < 0) {\n\t\tthrow new TypeError(\n\t\t\t`Parameter 'durationInMilliseconds' must be over 0 but it is ${durationInMilliseconds}.`,\n\t\t);\n\t}\n\n\tconst durationPrice = pricing[region]['Lambda Duration-ARM'].price;\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-client/src/estimate-price.ts#L35-L71","documentation":"Second guard in the estimatePrice validation chain: after the typeof check passes, Number.isNaN(durationInMilliseconds) is evaluated and a TypeError is thrown if true. This catches NaN that arises from bad arithmetic upstream (e.g. Number(undefined) is NaN but typeof kept it a number is impossible here — more commonly parseFloat failures passed through as number).","triggerScenarios":"durationInMilliseconds is the literal NaN value (e.g. produced by parseFloat('abc') or 0/0).","commonSituations":"Parsing user input with parseFloat without checking for NaN, downstream arithmetic that produced NaN.","solutions":["Validate the source of durationInMilliseconds with Number.isFinite before calling estimatePrice","Guard parseFloat results with Number.isNaN and reject early"],"exampleFix":"// before\nconst durationInMilliseconds = parseFloat(input);\nestimatePrice({ ..., durationInMilliseconds });\n\n// after\nconst durationInMilliseconds = Number(input);\nif (!Number.isFinite(durationInMilliseconds)) throw new Error('bad duration');\nestimatePrice({ ..., durationInMilliseconds });","handlingStrategy":"validation","validationCode":"const durationInMilliseconds = Number(input);\nif (Number.isNaN(durationInMilliseconds)) {\n  throw new Error('duration input is not numeric');\n}\nestimatePrice({ ..., durationInMilliseconds });","typeGuard":"const isDuration = (v: unknown): v is number => typeof v === 'number' && !Number.isNaN(v) && Number.isFinite(v) && v >= 0;","tryCatchPattern":null,"preventionTips":["Gate parseFloat/Number results with Number.isFinite before passing","Treat NaN as an input error at the boundary, not at the library"],"tags":["typescript","validation","api","nan"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}