{"record":{"id":"de49b016b4e50549","repo":"remotion-dev/remotion","slug":"trimbefore-prop-can-not-be-nan-or-infinity","errorCode":null,"errorMessage":"trimBefore prop can not be NaN or Infinity.","messagePattern":"trimBefore prop can not be NaN or Infinity\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/validate-start-from-props.ts","lineNumber":58,"sourceCode":"\n\tif ((endAt as number) < (startFrom as number)) {\n\t\tthrow new TypeError('endAt prop must be greater than startFrom prop.');\n\t}\n};\n\nexport const validateTrimProps = (\n\ttrimBefore: number | undefined,\n\ttrimAfter: number | undefined,\n) => {\n\tif (typeof trimBefore !== 'undefined') {\n\t\tif (typeof trimBefore !== 'number') {\n\t\t\tthrow new TypeError(\n\t\t\t\t`type of trimBefore prop must be a number, instead got type ${typeof trimBefore}.`,\n\t\t\t);\n\t\t}\n\n\t\tif (isNaN(trimBefore) || trimBefore === Infinity) {\n\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.');","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/validate-start-from-props.ts#L40-L76","documentation":"Even when trimBefore is a number, validateTrimProps rejects NaN and Infinity because neither represents a valid frame offset. NaN typically comes from a failed Number() conversion; Infinity comes from division by zero. Both would yield undefined seek behavior.","triggerScenarios":"Passing trimBefore={NaN} (e.g. Number('abc')), trimBefore={Infinity} (e.g. 1/0), or any expression evaluating to NaN/Infinity.","commonSituations":"Parsing user/CMS input with Number() that returns NaN; computing trimBefore with a division where the divisor can be zero; spreading unvalidated external props.","solutions":["Guard the value with Number.isFinite() before passing: trimBefore={Number.isFinite(v) ? v : undefined}.","Fix the upstream parse with a format check (regex/parseInt) before Number().","Omit the prop when the dynamic value cannot be guaranteed finite."],"exampleFix":"// before\nconst trimBefore = Number(userInput); // may be NaN\n<Video src={src} trimBefore={trimBefore} />\n// after\nconst raw = Number(userInput);\nconst trimBefore = Number.isFinite(raw) ? raw : undefined;\n<Video src={src} trimBefore={trimBefore} />","handlingStrategy":"validation","validationCode":"if (trimBefore !== undefined && !Number.isFinite(trimBefore)) {\n  throw new Error('trimBefore must be a finite number');\n}","typeGuard":"const isFiniteTrimBefore = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isFinite(v) && v >= 0;","tryCatchPattern":null,"preventionTips":["Always validate parsed numbers with Number.isFinite() before assigning to trimBefore.","Guard divisors against zero to avoid Infinity.","Do not spread untyped external props directly onto media components."],"tags":["validation","props","trimming","nan","infinity"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}