remotion-dev/remotion · error · Error

Lambda function returned error: ${res.FunctionError} ${res.L

Error message

Lambda function returned error: ${res.FunctionError} ${res.LogResult}

What it means

Thrown after a synchronous InvokeCommand when res.FunctionError is truthy. Lambda sets FunctionError when the handler itself raised (Unhandled) or returned a structured error (Handled). The message embeds the FunctionError code and the base64 LogResult so the function's own logs can be decoded.

Source

Thrown at packages/lambda-client/src/call-lambda-sync.ts:37

	timeoutInTest,
}: CallFunctionOptions<T, Provider>): Promise<
	OrError<ServerlessReturnValues<Provider>[T]>
> => {
	const Payload = JSON.stringify(payload);
	const res = await getLambdaClient(
		region as AwsRegion,
		timeoutInTest,
		null,
	).send(
		new InvokeCommand({
			FunctionName: functionName,
			Payload,
			InvocationType: 'RequestResponse',
		}),
	);

	if (res.FunctionError) {
		throw new Error(
			`Lambda function returned error: ${res.FunctionError} ${res.LogResult}`,
		);
	}

	if (!res.Payload) {
		throw new Error(
			`Lambda function returned no payload (status ${res.StatusCode})`,
		);
	}

	const decoded = new TextDecoder('utf-8').decode(res.Payload);

	try {
		return JSON.parse(decoded) as OrError<ServerlessReturnValues<Provider>[T]>;
	} catch {
		throw new Error(`Invalid JSON: ${JSON.stringify(decoded)}`);
	}
};

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Base64-decode the LogResult embedded in the error message to read the function's console output
  2. If logs show OOM/timeout, raise memorySizeInMb or the function timeout and redeploy
  3. Ensure the deployed function version matches the @remotion/lambda-client version
  4. Open the CloudWatch log group for the function for the failing requestId

Example fix

// decode the LogResult field from the thrown message
try {
  await getCompositionsOnLambda({...});
} catch (err) {
  const m = (err as Error).message.match(/LogResult\'?\s*=?\s*([A-Za-z0-9+/=]+)/);
  if (m) console.log(Buffer.from(m[1], 'base64').toString('utf-8'));
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await getCompositionsOnLambda({...});
} catch (err) {
  const msg = (err as Error).message;
  if (msg.startsWith('Lambda function returned error')) {
    const logResult = msg.split(' ').pop(); // base64 LogResult token
    const logs = logResult ? Buffer.from(logResult, 'base64').toString('utf-8') : '';
    // handle: log, bump memory, redeploy
  }
  throw err;
}

Prevention

When it happens

Trigger: Any sync routine (getCompositionsOnLambda, non-streaming getRenderProgress, deleteRender, etc.) where the Lambda function code threw an exception. FunctionError is checked before payload decoding.

Common situations: Function OOM (memorySizeInMb too low), function timeout, version mismatch between lambda-client and deployed function, bad input that crashes the handler.

Related errors


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