{"record":{"id":"0dbd8786163ffc45","repo":"remotion-dev/remotion","slug":"trimafter-prop-can-not-be-nan","errorCode":null,"errorMessage":"trimAfter prop can not be NaN.","messagePattern":"trimAfter prop can not be NaN\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/validate-start-from-props.ts","lineNumber":76,"sourceCode":"\t\t\tthrow new TypeError('trimBefore prop can not be NaN or Infinity.');\n\t\t}\n\n\t\tif (trimBefore < 0) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`trimBefore must be greater than equal to 0 instead got ${trimBefore}.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (typeof trimAfter !== 'undefined') {\n\t\tif (typeof trimAfter !== 'number') {\n\t\t\tthrow new TypeError(\n\t\t\t\t`type of trimAfter prop must be a number, instead got type ${typeof trimAfter}.`,\n\t\t\t);\n\t\t}\n\n\t\tif (isNaN(trimAfter)) {\n\t\t\tthrow new TypeError('trimAfter prop can not be NaN.');\n\t\t}\n\n\t\tif (trimAfter <= 0) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`trimAfter must be a positive number, instead got ${trimAfter}.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif ((trimAfter as number) <= (trimBefore as number)) {\n\t\tthrow new TypeError('trimAfter prop must be greater than trimBefore prop.');\n\t}\n};\n\nexport const validateMediaTrimProps = ({\n\tstartFrom,\n\tendAt,\n\ttrimBefore,","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/validate-start-from-props.ts#L58-L94","documentation":"validateTrimProps rejects NaN for trimAfter because NaN cannot represent a valid end frame and would silently break the stop-time calculation. (Note: only NaN is checked here, mirroring the endAt behavior; finiteness of trimAfter beyond NaN is not enforced at this check.)","triggerScenarios":"Passing trimAfter={NaN}, typically the result of Number('abc'), parseFloat on a non-numeric string, or arithmetic on an undefined value.","commonSituations":"Parsing an end timestamp from user/CMS input with Number()/parseFloat() that yields NaN; computing trimAfter from a duration that is itself undefined.","solutions":["Guard the parsed value with Number.isFinite() before passing it.","Fix the upstream string-to-number conversion (validate input format first).","Omit the prop if the dynamic value cannot be guaranteed to be a valid number."],"exampleFix":"// before\nconst trimAfter = Number(rawEnd); // NaN if rawEnd is non-numeric\n<Video src={src} trimAfter={trimAfter} />\n// after\nconst parsed = Number(rawEnd);\nconst trimAfter = Number.isFinite(parsed) ? parsed : undefined;\n<Video src={src} trimAfter={trimAfter} />","handlingStrategy":"validation","validationCode":"if (trimAfter !== undefined && Number.isNaN(trimAfter)) {\n  throw new Error('trimAfter must not be NaN');\n}","typeGuard":"const isValidTrimAfter = (v: unknown): v is number =>\n  typeof v === 'number' && !Number.isNaN(v);","tryCatchPattern":null,"preventionTips":["Guard parsed values with Number.isFinite() before assigning to trimAfter.","Validate the format of user/CMS input before Number()/parseFloat().","Default unset variables to undefined rather than a NaN-producing expression."],"tags":["validation","props","trimming","nan"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}