remotion-dev/remotion · error · Error

Memory size must be a positive integer. Received: ${memorySi

Error message

Memory size must be a positive integer. Received: ${memorySizeInMb}

What it means

speculateFunctionName validates its inputs before composing the Lambda function name. memorySizeInMb is coerced via Number(); if the result is not an integer or is <= 0, this error is thrown. The input type is string|number, so non-numeric strings produce NaN and fail this check.

Source

Thrown at packages/lambda-client/src/speculate-function-name.ts:38

		`${timeoutInSeconds}sec`,
	].join('-');
};

/*
 * @description Speculate the name of the Lambda function that will be created by `deployFunction()` or its CLI equivalent, based on the function configuration.
 * @see [Documentation](https://remotion.dev/docs/lambda/speculatefunctionname)
 */
export const speculateFunctionName = ({
	memorySizeInMb,
	diskSizeInMb,
	timeoutInSeconds,
}: SpeculateFunctionNameInput) => {
	const memorySize = Number(memorySizeInMb);
	const diskSize = Number(diskSizeInMb);
	const timeout = Number(timeoutInSeconds);

	if (!Number.isInteger(memorySize) || memorySize <= 0) {
		throw new Error(
			`Memory size must be a positive integer. Received: ${memorySizeInMb}`,
		);
	}

	if (!Number.isInteger(diskSize) || diskSize <= 0) {
		throw new Error(
			`Disk size must be a positive integer. Received: ${diskSizeInMb}`,
		);
	}

	if (!Number.isInteger(timeout) || timeout <= 0) {
		throw new Error(
			`Timeout must be a positive integer. Received: ${timeoutInSeconds}`,
		);
	}

	return innerSpeculateFunctionName({
		diskSizeInMb,

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Pass a positive integer for memorySizeInMb (Lambda allows 128 to 10240 in 1-MB steps; Remotion recommends >= 512).
  2. If reading from env, validate and coerce with Number() and Number.isInteger() before calling.
  3. Use validateMemorySize() from the same package for full range validation.

Example fix

// before
speculateFunctionName({ memorySizeInMb: 'fast', diskSizeInMb: 2048, timeoutInSeconds: 120 });

// after
speculateFunctionName({ memorySizeInMb: 2048, diskSizeInMb: 2048, timeoutInSeconds: 120 });
Defensive patterns

Strategy: validation

Validate before calling

const mem = Number(memorySizeInMb);
if (!Number.isInteger(mem) || mem <= 0) {
  throw new Error(`memorySizeInMb must be a positive integer, got ${memorySizeInMb}`);
}
speculateFunctionName({ memorySizeInMb: mem, diskSizeInMb, timeoutInSeconds });

Type guard

const isPositiveInteger = (v: unknown): v is number =>
  typeof v === 'number' && Number.isInteger(v) && v > 0;

Prevention

When it happens

Trigger: Calling speculateFunctionName (or deployFunction's name prediction) with memorySizeInMb that Number() cannot turn into a positive integer — e.g. 0, -1, 2048.5, 'abc', '', null, undefined.

Common situations: Reading memorySizeInMb from an env var or CLI arg as a string and passing an empty/garbage value; passing a fractional value; defaulting to 0; off-by-one in config builders.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/3720f1409037f7f1. Report an issue: GitHub.