remotion-dev/remotion · error · TypeError
parameter 'memorySizeInMb' must not be NaN, but is
Error message
parameter 'memorySizeInMb' must not be NaN, but is
What it means
Thrown by validateMemorySize() in @remotion/lambda-client when the memorySizeInMb option is the numeric value NaN. Remotion Lambda must allocate a concrete amount of memory to the render function (between 512 and 10240 MB), and NaN is not an allocatable size. The check runs after the typeof guard, so only a real number that is NaN reaches it.
Source
Thrown at packages/lambda-client/src/validate-memory-size.ts:11
import {MAX_MEMORY, MIN_MEMORY} from './constants';
export const validateMemorySize = (memorySizeInMb: unknown) => {
if (typeof memorySizeInMb !== 'number') {
throw new TypeError(
`parameter 'memorySizeInMb' must be a number, got a ${typeof memorySizeInMb}`,
);
}
if (Number.isNaN(memorySizeInMb)) {
throw new TypeError(`parameter 'memorySizeInMb' must not be NaN, but is`);
}
if (!Number.isFinite(memorySizeInMb)) {
throw new TypeError(
`parameter 'memorySizeInMb' must be finite, but is ${memorySizeInMb}`,
);
}
if (memorySizeInMb < MIN_MEMORY || memorySizeInMb > MAX_MEMORY) {
throw new TypeError(
`parameter 'memorySizeInMb' must be between ${MIN_MEMORY} and ${MAX_MEMORY}, but got ${memorySizeInMb}`,
);
}
if (memorySizeInMb % 1 !== 0) {
throw new TypeError(
`parameter 'memorySizeInMb' must be an integer but got ${memorySizeInMb}`,
);View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Check the upstream source of memorySizeInMb and ensure it is a finite integer before passing it; default to DEFAULT_MEMORY_SIZE (2048) when the value is missing or NaN.
- Wrap the read with Number.isFinite() and fall back to a sane default rather than forwarding NaN.
- If accepting user input, validate the raw string with /^\d+$/ before coercing to a number.
Example fix
// before
const memorySizeInMb = Number(process.env.REMOTION_MEMORY);
await renderMediaOnLambda({memorySizeInMb, ...});
// after
const parsed = Number(process.env.REMOTION_MEMORY);
const memorySizeInMb = Number.isFinite(parsed) ? parsed : 2048;
await renderMediaOnLambda({memorySizeInMb, ...}); Defensive patterns
Strategy: type-guard
Validate before calling
const safeMemory = (v: unknown): number => {
const n = typeof v === 'string' ? Number(v) : v;
return typeof n === 'number' && !Number.isNaN(n) && Number.isFinite(n) ? n : 2048;
};
await renderMediaOnLambda({memorySizeInMb: safeMemory(raw), ...}); Type guard
const isMemorySize = (v: unknown): v is number => typeof v === 'number' && !Number.isNaN(v) && Number.isFinite(v) && v >= 512 && v <= 10240 && v % 1 === 0;
Prevention
- Always coerce and validate memorySizeInMb at the config boundary, not at the Lambda call site.
- Default to DEFAULT_MEMORY_SIZE (2048) when input is missing or non-numeric.
- Add a unit test that feeds NaN / undefined / Infinity to your config loader and asserts a sane default.
When it happens
Trigger: Calling renderMediaOnLambda() / deploySite() / simulatePermissions() with memorySizeInMb set to the result of a failed Number parse (Number(undefined) === NaN), parseFloat on a non-numeric string, or an arithmetic expression that yields NaN (e.g. 0/0).
Common situations: Reading memorySizeInMb from an environment variable or JSON config without coercion, e.g. Number(process.env.REMOTION_MEMORY) where the env var is unset; computing memory from a formula whose divisor is zero; a CLI flag that parses to undefined then gets Number()-ed.
Related errors
- maxRetries must be a number, but is ${JSON.stringify(maxRetr
- parameter 'memorySizeInMb' must be finite, but is ${memorySi
- parameter 'memorySizeInMb' must be an integer but got ${memo
- 'expiresIn' should be a number, but is ${JSON.stringify(pres
- maxRetries must be a number, but is ${JSON.stringify(maxRetr
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/d1f068cb5b414dcd.
Report an issue: GitHub.