remotion-dev/remotion · error · TypeError
parameter 'diskSizeInMb' must not be NaN, but is
Error message
parameter 'diskSizeInMb' must not be NaN, but is
What it means
Second guard in validateDiskSizeInMb: after confirming the value is a number, it must not be NaN. NaN passes typeof === 'number' but represents an unparseable numeric, so this catches Number('abc')-style inputs that slipped past the type check.
Source
Thrown at packages/lambda-client/src/validate-disk-size-in-mb.ts:14
import {
MAX_EPHEMERAL_STORAGE_IN_MB,
MIN_EPHEMERAL_STORAGE_IN_MB,
} from './constants';
export const validateDiskSizeInMb = (diskSizeInMb: unknown) => {
if (typeof diskSizeInMb !== 'number') {
throw new TypeError(
`parameter 'diskSizeInMb' must be a number, got a ${typeof diskSizeInMb}`,
);
}
if (Number.isNaN(diskSizeInMb)) {
throw new TypeError(`parameter 'diskSizeInMb' must not be NaN, but is`);
}
if (!Number.isFinite(diskSizeInMb)) {
throw new TypeError(
`parameter 'diskSizeInMb' must be finite, but is ${diskSizeInMb}`,
);
}
if (
diskSizeInMb < MIN_EPHEMERAL_STORAGE_IN_MB ||
diskSizeInMb > MAX_EPHEMERAL_STORAGE_IN_MB
) {
throw new TypeError(
`parameter 'diskSizeInMb' must be between ${MIN_EPHEMERAL_STORAGE_IN_MB} and ${MAX_EPHEMERAL_STORAGE_IN_MB}, but got ${diskSizeInMb}`,
);
}
if (diskSizeInMb % 1 !== 0) {View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Validate the source string parses cleanly with !Number.isNaN(Number(x)) before calling.
- Provide a numeric default when the env var is absent.
- Log the raw input value to find where NaN originates.
Example fix
// before const disk = Number(readConfig().diskSize); // NaN if config missing/garbage validateDiskSizeInMb(disk); // after const raw = readConfig().diskSize; const disk = raw == null || Number.isNaN(Number(raw)) ? 2048 : Number(raw); validateDiskSizeInMb(disk);
Defensive patterns
Strategy: validation
Validate before calling
const disk = Number(diskSizeInMb);
if (Number.isNaN(disk)) {
throw new TypeError(`diskSizeInMb is NaN; source value was ${diskSizeInMb}`);
}
validateDiskSizeInMb(disk); Type guard
const isNonNaNNumber = (v: unknown): v is number => typeof v === 'number' && !Number.isNaN(v);
Prevention
- Validate Number.isNaN() at the config boundary.
- Provide a numeric default when env vars are missing.
- Log raw string inputs that fail to parse.
When it happens
Trigger: Calling validateDiskSizeInMb with the literal NaN, or with Number(someUnparseableString) (e.g., Number('big-disk')) that yields NaN.
Common situations: Coercing a non-numeric env var with Number() and passing the NaN result; arithmetic on undefined producing NaN; JSON parse yielding NaN-shaped values.
Related errors
- parameter 'diskSizeInMb' must be a number, got a ${typeof di
- parameter 'diskSizeInMb' must be finite, but is ${diskSizeIn
- Disk size must be a positive integer. Received: ${diskSizeIn
- parameter 'diskSizeInMb' must be between ${MIN_EPHEMERAL_STO
- parameter 'diskSizeInMb' must be an integer but got ${diskSi
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/7b88fa3867c94e26.
Report an issue: GitHub.