remotion-dev/remotion · error · TypeError
trimAfter prop can not be NaN.
Error message
trimAfter prop can not be NaN.
What it means
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.)
Source
Thrown at packages/core/src/validate-start-from-props.ts:76
throw new TypeError('trimBefore prop can not be NaN or Infinity.');
}
if (trimBefore < 0) {
throw new TypeError(
`trimBefore must be greater than equal to 0 instead got ${trimBefore}.`,
);
}
}
if (typeof trimAfter !== 'undefined') {
if (typeof trimAfter !== 'number') {
throw new TypeError(
`type of trimAfter prop must be a number, instead got type ${typeof trimAfter}.`,
);
}
if (isNaN(trimAfter)) {
throw new TypeError('trimAfter prop can not be NaN.');
}
if (trimAfter <= 0) {
throw new TypeError(
`trimAfter must be a positive number, instead got ${trimAfter}.`,
);
}
}
if ((trimAfter as number) <= (trimBefore as number)) {
throw new TypeError('trimAfter prop must be greater than trimBefore prop.');
}
};
export const validateMediaTrimProps = ({
startFrom,
endAt,
trimBefore,View on GitHub (pinned to 78fe4bb3fd)
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.
Example fix
// before
const trimAfter = Number(rawEnd); // NaN if rawEnd is non-numeric
<Video src={src} trimAfter={trimAfter} />
// after
const parsed = Number(rawEnd);
const trimAfter = Number.isFinite(parsed) ? parsed : undefined;
<Video src={src} trimAfter={trimAfter} /> Defensive patterns
Strategy: validation
Validate before calling
if (trimAfter !== undefined && Number.isNaN(trimAfter)) {
throw new Error('trimAfter must not be NaN');
} Type guard
const isValidTrimAfter = (v: unknown): v is number => typeof v === 'number' && !Number.isNaN(v);
Prevention
- 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.
When it happens
Trigger: Passing trimAfter={NaN}, typically the result of Number('abc'), parseFloat on a non-numeric string, or arithmetic on an undefined value.
Common situations: Parsing an end timestamp from user/CMS input with Number()/parseFloat() that yields NaN; computing trimAfter from a duration that is itself undefined.
Related errors
- startFrom prop can not be NaN or Infinity.
- endAt prop can not be NaN.
- trimBefore prop can not be NaN or Infinity.
- The "trimBefore" prop of <Sequence /> must be a real number,
- type of startFrom prop must be a number, instead got type ${
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/0dbd8786163ffc45.
Report an issue: GitHub.